💥 Simplifica renderizado de estilos y javascripts
Elimina la necesidad de incluir la versión como un campo más del activo.
Será buena práctica de los desarrolladores incluir la versión
("?v=X.Y.Z") en la propia localización del activo, ya sea una hoja de
estilos o un archivo JavaScript.
This commit is contained in:
parent
e033630d2a
commit
ea782f820d
2 changed files with 2 additions and 29 deletions
|
|
@ -13,8 +13,6 @@ pub enum ModeJS {
|
|||
#[derive(Default)]
|
||||
pub struct JavaScript {
|
||||
source : String,
|
||||
prefix : &'static str,
|
||||
version: &'static str,
|
||||
weight : isize,
|
||||
mode : ModeJS,
|
||||
}
|
||||
|
|
@ -31,7 +29,7 @@ impl AssetsTrait for JavaScript {
|
|||
fn prepare(&self) -> Markup {
|
||||
html! {
|
||||
script type="text/javascript"
|
||||
src=(crate::concat_string!(self.source, self.prefix, self.version))
|
||||
src=(self.source)
|
||||
async[self.mode == ModeJS::Async]
|
||||
defer[self.mode == ModeJS::Defer]
|
||||
{};
|
||||
|
|
@ -50,15 +48,6 @@ impl JavaScript {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn with_version(mut self, version: &'static str) -> Self {
|
||||
(self.prefix, self.version) = if version.is_empty() {
|
||||
("", "")
|
||||
} else {
|
||||
("?ver=", version)
|
||||
};
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ pub enum TargetMedia {
|
|||
#[derive(Default)]
|
||||
pub struct StyleSheet {
|
||||
source : String,
|
||||
prefix : &'static str,
|
||||
version: &'static str,
|
||||
media : Option<&'static str>,
|
||||
weight : isize,
|
||||
}
|
||||
|
|
@ -28,12 +26,7 @@ impl AssetsTrait for StyleSheet {
|
|||
}
|
||||
|
||||
fn prepare(&self) -> Markup {
|
||||
html! {
|
||||
link
|
||||
rel="stylesheet"
|
||||
href=(crate::concat_string!(self.source, self.prefix, self.version))
|
||||
media=[self.media];
|
||||
}
|
||||
html! { link rel="stylesheet" href=(self.source) media=[self.media]; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,15 +41,6 @@ impl StyleSheet {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn with_version(mut self, version: &'static str) -> Self {
|
||||
(self.prefix, self.version) = if version.is_empty() {
|
||||
("", "")
|
||||
} else {
|
||||
("?ver=", version)
|
||||
};
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_weight(mut self, weight: isize) -> Self {
|
||||
self.weight = weight;
|
||||
self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue