pub struct ScriptTag {
pub src: Option<Cow<'static, str>>,
pub content: Option<Cow<'static, str>>,
pub type_attr: Option<Cow<'static, str>>,
pub is_async: bool,
pub is_defer: bool,
pub crossorigin: Option<Cow<'static, str>>,
pub integrity: Option<Cow<'static, str>>,
pub nonce: Option<Cow<'static, str>>,
}Expand description
Represents an HTML <script> tag.
Script tags can reference external scripts or contain inline JavaScript.
Fields§
§src: Option<Cow<'static, str>>The src attribute for external scripts.
content: Option<Cow<'static, str>>Inline script content.
type_attr: Option<Cow<'static, str>>The type attribute (e.g., “module”, “text/javascript”).
is_async: boolWhether to add async attribute.
is_defer: boolWhether to add defer attribute.
crossorigin: Option<Cow<'static, str>>The crossorigin attribute.
integrity: Option<Cow<'static, str>>The integrity attribute for SRI.
nonce: Option<Cow<'static, str>>The nonce attribute for CSP.
Implementations§
Source§impl ScriptTag
impl ScriptTag
Sourcepub fn external(src: impl Into<Cow<'static, str>>) -> ScriptTag
pub fn external(src: impl Into<Cow<'static, str>>) -> ScriptTag
Creates a new external script tag.
Sourcepub fn inline(content: impl Into<Cow<'static, str>>) -> ScriptTag
pub fn inline(content: impl Into<Cow<'static, str>>) -> ScriptTag
Creates a new inline script tag.
Sourcepub fn with_async(self) -> ScriptTag
pub fn with_async(self) -> ScriptTag
Sets the script to async.
Sourcepub fn with_defer(self) -> ScriptTag
pub fn with_defer(self) -> ScriptTag
Sets the script to defer.
Sourcepub fn with_type(self, type_attr: impl Into<Cow<'static, str>>) -> ScriptTag
pub fn with_type(self, type_attr: impl Into<Cow<'static, str>>) -> ScriptTag
Sets the type attribute.
Sourcepub fn with_crossorigin(
self,
crossorigin: impl Into<Cow<'static, str>>,
) -> ScriptTag
pub fn with_crossorigin( self, crossorigin: impl Into<Cow<'static, str>>, ) -> ScriptTag
Sets the crossorigin attribute.
Sourcepub fn with_integrity(
self,
integrity: impl Into<Cow<'static, str>>,
) -> ScriptTag
pub fn with_integrity( self, integrity: impl Into<Cow<'static, str>>, ) -> ScriptTag
Sets the integrity attribute for SRI.
Trait Implementations§
impl StructuralPartialEq for ScriptTag
Auto Trait Implementations§
impl Freeze for ScriptTag
impl RefUnwindSafe for ScriptTag
impl Send for ScriptTag
impl Sync for ScriptTag
impl Unpin for ScriptTag
impl UnsafeUnpin for ScriptTag
impl UnwindSafe for ScriptTag
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more