Represents a single web resource declaration parsed out of the head of a theme or content template - typically a script, link or meta tag, or a raw HTML comment. Templates are parsed once and the resulting list of these is cached, then merged and written into the final rendered page head by the rendering pipeline. The static param, meta and metaList helper methods look up specific entries in a page's resource list by convention: a param is a script tag with type data/parameter carrying a lookup name in its title attribute, and a meta is a meta tag matched by its name attribute.
Group: Resources
Properties
| Property | Returns | Description |
|---|---|---|
| atts | Map<String,String> | Mutable map of this tag's attributes, keyed by attribute name, for example src, property, content or type. |
| body | String | Text placed between the opening and closing tag, such as the source of an inline script. Null or empty for a self-closing tag, or for the comment text itself when this resource represents a raw comment. |
| rawHtml | String | Renders this resource as an HTML tag (or raw comment text) using its attribute values exactly as stored, without rewriting relative href or src paths. |
| tag | String | HTML tag name for this resource, for example script, link or meta. Empty if this resource represents a raw comment rather than a tag. |
Methods
getTag()
Returns: String
HTML tag name for this resource, for example script, link or meta. Empty if this resource represents a raw comment rather than a tag.
getAtts()
Returns: Map<String,String>
Mutable map of this tag's attributes, keyed by attribute name, for example src, property, content or type.
getBody()
Returns: String
Text placed between the opening and closing tag, such as the source of an inline script. Null or empty for a self-closing tag, or for the comment text itself when this resource represents a raw comment.
toHtml(String themeName, Path webPath)
Returns: String
Renders this resource as an HTML tag (or raw comment text), rewriting any relative href or src attribute value against the current theme and page path via adjustRelativePath.
| Parameter | Description |
|---|---|
themeName | the name of the theme currently in use, used to rewrite hard-coded theme references |
webPath | path of the directory containing the template or page that declared this resource |
getRawHtml()
Returns: String
Renders this resource as an HTML tag (or raw comment text) using its attribute values exactly as stored, without rewriting relative href or src paths.
adjustRelativePath(String name, String value, String themeName, Path webPath)
Returns: String
If the attribute name is href or src and its value is a relative path, resolves it to an absolute path rooted under /templates, rewriting any hard-coded theme segment to the current theme along the way. Values that are already absolute or that start with http are returned unchanged.
| Parameter | Description |
|---|---|
name | the attribute name being checked, only href and src are adjusted |
value | the attribute's current value |
themeName | the name of the theme currently in use, used to rewrite hard-coded theme references |
webPath | path of the directory containing the template or page that declared this resource |
duplicate()
Returns: WebResource
Creates a copy of this web resource, including a shallow copy of its attribute map.