HTML templating module: utility template functions. Newly added templating functions should go here and not into templates.xqm.
author | Wolfgang Meier |
lib:include($node as node(), $model as map(*), $path as xs:string) as item()*
Include an HTML fragment from another file as given in parameter $path. The children (if any) of the including element (i.e. the one triggering the lib:include function) are merged into the included content. To define where a child element should be inserted, you must use a
$node | $node |
$model | $model |
$path | $path |
lib:parse-params($node as node(), $model as map(*), $start as xs:string?, $end as xs:string?) as item()*
Recursively expand template expressions appearing in attributes or text content,
trying to expand them from request/session parameters or the current model.
Template expressions by default should have the form ${paramName:default text}.
You can change the used delimiters from `${` and `}` to something else by
overwriting the parameters $start and $end.
Specifying a default is optional. If there is no default and the parameter
cannot be expanded, the empty string is output.
To support navigating the map hierarchy of the model, paramName may be a sequence
of map keys separated by ?, i.e. ${address?street} would first retrieve the map
property called "address" and then look up the property "street" on it.
The templating function should fail gracefully if a parameter or map lookup cannot
be resolved, a lookup resolves to multiple items, a map or an array.
$node | $node |
$model | $model |
$start? | $start? |
$end? | $end? |
lib:resolve-apps($node as node(), $model as map(*), $abbrev as xs:string) as item()*
Resolve the expath application package identified by $abbrev. If an installed
application is found, a property is added to the model. The name of the property
will correspond to $abbrev and its value to the absolute URI path at which the
root of the application can be found.
Use e.g. with lib:parse-params to expand URLs.
$abbrev may list more than one package abbreviation separated by ",".
$node | $node |
$model | $model |
$abbrev | $abbrev |