Documentation
¶
Overview ¶
Package template implements Ansible's templating semantics on top of a Jinja2-compatible engine (github.com/nikolalohinski/gonja/v2): string interpolation with {{ }}, control structures with {% %}, Ansible's own filter and test library on top of the Jinja2 built-ins, and Ansible's rule that a value which is a SINGLE {{ expr }} with nothing else around it renders to the expression's native type (list, dict, int, bool...), not a string.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTemplate ¶
IsTemplate reports whether s contains any Jinja2 delimiter ({{, {%, or {#) and therefore needs rendering at all.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine renders Ansible-flavored Jinja2 templates and expressions.
func New ¶
func New() *Engine
New returns an Engine with Jinja2's built-in filters/tests plus Ansible's filter and test library.
func (*Engine) Eval ¶
Eval evaluates a single Jinja2 expression (no {{ }} wrapper — e.g. the raw text of an Ansible `when:` condition, or the inside of a wholeExpression string) and returns its native Go value.
func (*Engine) EvalBool ¶
EvalBool evaluates exprSrc and applies Ansible/Jinja2 truthiness — the semantics of a `when:` condition.
func (*Engine) Render ¶
Render renders a full template string (text mixed with {{ }} / {% %}) to its string form.
func (*Engine) RenderValue ¶
RenderValue applies Ansible's templating rule to an arbitrary decoded YAML value: strings are templated (with the whole-expression rule preserving native types), and lists/maps are walked recursively so a nested `{{ }}` anywhere in a task's arguments is resolved. Non-string scalars pass through unchanged.