classafDuvet::ScriptTagBuilder

sys::Obj
  afDuvet::ScriptTagBuilder

Defines a <script> tag to be injected into the bottom of your body. Created via HtmlInjector.

Note that any Content-Security-Policy response header will be updated to ensure the script can be executed.

@see https://developer.mozilla.org/en/docs/Web/HTML/Element/script

async

Source

ScriptTagBuilder async()

Sets the async attribute to async; the XHTML value, accepted by HTML. Returns this.

defer

Source

ScriptTagBuilder defer()

Sets the defer attribute to true. Returns this.

fromExternalUrl

Source

ScriptTagBuilder fromExternalUrl(Uri scriptUrl)

Sets the src attribute to an external, absolute, URL. Returns this.

fromExternalUrl(`http://example.com/css/maxStyles.css`)
fromLocalUrl

Source

ScriptTagBuilder fromLocalUrl(Uri scriptUrl)

Sets the src attribute to a local URL. The URL may be rebuilt to take advantage of any asset caching strategies, such as Cold Feet. Returns this.

fromLocalUrl(`/css/maxStyles.css`)
fromServerFile

Source

ScriptTagBuilder fromServerFile(File scriptFile)

Creates a src URL attribute from the given file. The file must exist on the file system and be mapped by BedSheet's FileHandler service. The URL is built to take advantage of any asset caching strategies, such as Cold Feet. Returns this.

fromServerFile(File(`web-static/css/maxStyles.css`))
getAttr

Source

Str? getAttr(Str name)

Returns an attribute value on the <script> element.

setAttr

Source

ScriptTagBuilder setAttr(Str name, Str value)

Sets an arbitrary attribute on the <script> element.

withId

Source

ScriptTagBuilder withId(Str id)

Sets the id attribute. Returns this.

withScript

Source

ScriptTagBuilder withScript(Str script)

Sets the contents of the script tag. Returns this.

withType

Source

ScriptTagBuilder withType(MimeType type)

Sets the type attribute. Returns this.