Documentation
¶
Overview ¶
Package template — list resolution.
Shared resolution path for inputs that need to be a []string but may arrive as: a Go slice already in the variable map (e.g. `[]string` loaded by include_vars), a template expression that renders to a YAML/JSON list literal, a Pongo2-stringified Go slice ("[a b c]"), or a whitespace/comma separated scalar. Used by `with_items` (planner) and `package.names`.
Package template provides template rendering functionality using pongo2.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveList ¶ added in v0.5.0
func ResolveList(expr string, vars map[string]interface{}, evaluator expression.Evaluator) ([]interface{}, error)
ResolveList resolves a string expression to a list of items.
Order of attempts (first match wins; later steps only run if earlier steps could not establish a binding for `expr`):
- If `expr` is the exact name of a variable, require its value to be a list (returns an error otherwise — strict, preserves with_items semantics).
- Otherwise evaluate via the expression evaluator (supports dot notation). If evaluation succeeds, require the result to be a list.
- If neither path bound `expr` to a value, parse the expression itself as a literal list/scalar (handles rendered strings like "[a, b]" or "a b c").
The returned slice is []interface{} for compatibility with `with_items`, which uses interface{} per iteration item. Callers needing []string can use ResolveStringList.
func ResolveStringList ¶ added in v0.5.0
func ResolveStringList(expr string, vars map[string]interface{}, evaluator expression.Evaluator) ([]string, error)
ResolveStringList resolves a string expression to []string. Non-string items are formatted with %v.
Types ¶
type Pongo2Renderer ¶
type Pongo2Renderer struct {
// contains filtered or unexported fields
}
Pongo2Renderer implements Renderer using the pongo2 template engine.
type Renderer ¶
type Renderer interface {
Render(template string, variables map[string]interface{}) (string, error)
}
Renderer defines the interface for template rendering.
func NewPongo2Renderer ¶
NewPongo2Renderer creates a new Pongo2Renderer with filters registered. Returns an error if filter registration fails (e.g., filter name already registered).