cb:assetPath
Resolves the public path to the assets directory of a Content Block.
Use it together with the Core
f: and
f:
ViewHelpers to include CSS and JavaScript files, which are shipped inside the
Content Block itself.
Warning
This ViewHelper only works inside the template of a Content Block. It
resolves the current Content Block via the
data._ or
settings._ template variable. If neither
variable is available (for example when called from a partial rendered
completely outside of a Content Block context) and
name
is not
given explicitly, an exception is thrown.
Arguments
| Name | Type | Default | Required |
|---|---|---|---|
| string |
-
- Type
- string
The target Content Block name (
vendor/). If not set, the current Content Block is resolved automatically.name
Examples
Default usage
Inside the current Content Block's own template,
name
can be omitted.
The current Content Block is detected automatically.
<f:asset.css identifier="myCssIdentifier" href="{cb:assetPath()}/frontend.css"/>
<f:asset.script identifier="myJavascriptIdentifier" src="{cb:assetPath()}/frontend.js"/>
Explicit Content Block name
You can also point to the assets of a different Content Block by setting
name
explicitly.
<f:asset.script identifier="myJavascriptIdentifier" src="{cb:assetPath(name: 'vendor/name')}/frontend.js"/>