Thymeleaf dialect

AcrossWebModule also registers a custom Thymeleaf dialect. The Thymeleaf dialect uses the prefix across and offers a number of utility elements, attributes and expression objects.

Element processors

The AcrossWebDialect adds the following elements that can be used in HTML templates:

Name Description Attributes

across:view

Takes a ViewElement as element attribute and will be replaced by the rendering of that ViewElement.

element : ViewElement instance

Attribute processors

The AcrossWebDialect adds the following attributes that can be used in HTML templates:

Name Description Examples

across:resource

Takes a relative path to a static resource. Will generate a valid url path to that static resource and will write the value as a new attribute. The name of the attribute that will be written depends on the element the attribute is used on.

All HTML5 elements supporting src or href attributes are supported, along with image and use elements

<a across:resource="/img"/>
output: <a href="/res/img">

<script across:resource="/js/my.js"/>
output: <script src="/res/js/my.js"/>

<image across:resource="/img"/>
output: <image xlink:href="/res/img"/>

across:static

Takes a relative path to a resource in the static subfolder. Using across:static="/img" would be the same as using across:resource="/static/img". Supports the same elements as across:resource.

<a across:static="/img"/>
output: <a href="/res/static/img">

across:resource-attr-name

Same as across:resource except the resulting attribute name will be attr-name.
Any double dash (--) will be replaced by a colon (:).

<a across:resource-data-url="/img"/>
output: <a data-url="/res/img">

across:static-attr-name

Same as across:static except the resulting attribute name will be attr-name.
Any double dash (--) will be replaced by a colon (:).

<a across:static-data-url="/img"/>
output: <a data-url="/res/static/img">

Expression objects

The AcrossWebDialect makes the following expression objects available for script execution:

Name Value Description

#webapp

WebAppPathResolver

Used for generating prefixed links based on a relative path. For example to static resources.

These links can still be processed by the Thymeleaf link builder (@{..}). Usually not necessary to use the #webapp however, see the URL support section.

#htmlIdStore

HtmlIdStore

Holds the generated HTML id attribute for a ViewElement.

URL support

Apart from the availability of #webapp, AcrossWebModule activates transparent support for the WebAppPathResolver on Thymeleaf URL generation.

Example: <img th:src="@{@static:/img}"> would produce <img src="/res/static/img">