Class TemplateResolver.Builder
java.lang.Object
org.apache.juneau.commons.template.TemplateResolver.Builder
- Enclosing class:
- TemplateResolver
Builder for
TemplateResolver.-
Method Summary
Modifier and TypeMethodDescriptionallowFunctions(String... patterns) Adds function-name globs to the default allowlist (SafeFunctions.patterns()).allowOnlyFunctions(String... patterns) Replaces the default function allowlist (SafeFunctions.patterns()) with exactly these globs.build()Builds the resolver.destination(Destination value) Sets the default value encoder and structure renderer from a destination preset.functions(VarFunction... values) Registers additional functions.maxCollectionSize(int value) Sets the maximum number of elements one expression may iterate, and the maximum per container when formatting.strict(boolean value) Enables strict mode: an unknown or denied function, or an expression error, throws instead of being emitted as written.Sets how lists, blocks and tables are rendered.Registers additional vars.
-
Method Details
-
vars
Registers additional vars. None are registered by default except the internal scope var.- Parameters:
values- The vars. Must not benull . A var namedP replaces the scope var, which rebinds the${name} shortcut.- Returns:
- This object.
-
functions
Registers additional functions.- Parameters:
values- The functions. Must not benull . They are also subject to the allowlist.- Returns:
- This object.
-
allowFunctions
Adds function-name globs to the default allowlist (SafeFunctions.patterns()).Repeated calls are additive. A bare
* is rejected because it would switch default-deny off; useallowOnlyFunctions(String...)to replace the defaults.- Parameters:
patterns- The patterns. Must not benull , and must not be* .- Returns:
- This object.
- Throws:
IllegalArgumentException- If a pattern is* .
-
allowOnlyFunctions
Replaces the default function allowlist (SafeFunctions.patterns()) with exactly these globs.Include
$op.* to keep the operators. Patterns fromallowFunctions(String...)are still added. A bare* is rejected.- Parameters:
patterns- The patterns. Must not benull , and must not be* .- Returns:
- This object.
- Throws:
IllegalArgumentException- If a pattern is* .
-
strict
Enables strict mode: an unknown or denied function, or an expression error, throws instead of being emitted as written.- Parameters:
value- Whether to enable strict mode.- Returns:
- This object.
-
maxCollectionSize
Sets the maximum number of elements one expression may iterate, and the maximum per container when formatting.- Parameters:
value- The limit. Must be positive.- Returns:
- This object.
-
structureRenderer
Sets how lists, blocks and tables are rendered. Overrides the renderer ofdestination(Destination).Without a renderer
Structure.toString()is used, and its items are not encoded.- Parameters:
value- The renderer.null clears it.- Returns:
- This object.
-
destination
Sets the default value encoder and structure renderer from a destination preset.- Parameters:
value- The destination.null clears it.- Returns:
- This object.
-
build
Builds the resolver.- Returns:
- A new resolver.
-