Package org.apache.juneau.commons.template


package org.apache.juneau.commons.template
Safe, structured templates for template authors who are less trusted than the application.

A TemplateResolver wraps a VarResolver with a locked-down configuration: no system vars, a default-deny function allowlist, and a render scope supplied per render as a map. Templates use the SVL grammar: ${name} reads the scope, and #{...} expressions can read scope names as bare identifiers, project over collections (rows.![id]) and build lists and tables (ul(...), table(...)).

Destinations provides encoder and renderer presets (HTML, Markdown, plain text, JSON string, URL component), and TemplateResolver.check(String, org.apache.juneau.commons.template.TemplateCatalog) validates a template against the names an application offers before it is stored.

Encoding rule:

Escaping is applied to resolved values only, never to template text. The value encoder runs on the output of each top-level ${...} or #{...} segment, after any function inside it has run, so author literals inside an expression are encoded together with the data. A list or table result bypasses the encoder: the StructureRenderer encodes every item and cell itself and emits its own markup. Put markup outside #{...}, or use the structure functions.

Values are never re-parsed: a scope value that contains ${x} or #{1+1} is rendered as that text.