Krikri::VariableSubstitutor::VariableLookup
VariableLookup - Handles all forms of variable access
- Simple: {{ myvar }}
- Nested: {{ user.name.first }}
- Indexed: {{ array[0] }}, {{ dict['key'] }}
Constants
Constructors
Instance methods
Applies a dotted/method-call SUFFIX (e.g. "splitlines()", the
text after a lookup(...) call's own closing paren) to an
already-resolved value - used by ExpressionEvaluator's
filter_chain_special_head for lookup(...).method() chained
directly with no | filter in between (round 199, bodsch.tomcat).
Renders a variable's value the way Ansible/Jinja2 does when it's
interpolated directly into template text - notably, Python's
capitalized True/False for booleans, not Crystal's lowercase
true/false (verified against real ansible-playbook: a {{ boolvar }}
in a copy/template content string renders "True"/"False"). Public
(not just used internally) so FilterEngine's caller can render a
filter chain's final JSON::Any result the same way a plain variable
lookup would be.
The FINAL, user-facing rendering of a {{ }} span's value:
identical to #format_value except that a container comes out in
Python's repr form, which is what real Ansible produces
({{ ['a', 'b'] }} renders ['a', 'b'] there, and rendered
["a","b"] here). Only the outermost substitution may use this -
anything internal needs #format_value's JSON, per its comment.
Indexed access (array or hash) Example: mylist[0], mydict['key']
Nested variable access Example: user.name, config.database.host
Python's repr for a JSON::Any, used to render containers the
way real Ansible does. Scalars follow Python's own spellings
(True/False/None); strings follow its quote choice: single
quotes normally, double quotes when the string contains a single
quote and no double quote, and single quotes with \' escapes
when it contains both (verified against real Ansible's output
for all three shapes).
Resolves any of the three access forms above to its raw JSON::Any
value (nil if undefined) rather than a pre-stringified String - used
by FilterEngine so a filter chain ({{ x | sort | join(',') }}) can
carry real array/hash structure from one filter to the next instead
of collapsing to a string after every single filter.
Walks a dotted/indexed suffix (.stat.exists, "[0].name",
".days") against an already-resolved value, for a caller that
computed the base value itself (ExpressionEvaluator's
parenthesized-sub-expression handling: ( a - b ).days needs to
look .days up on the result of a - b, not on some variable
named "( a - b )") rather than looking it up from @vars the way
resolve/resolve_indexed/resolve_nested always do. An empty suffix
returns start unchanged.