Skip to content

Commit 871def2

Browse files
mattclaynitzmahone
authored andcommitted
Add another multi-pass templating example
1 parent 39bb9a9 commit 871def2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/docsite/rst/porting_guides/porting_guide_core_2.19.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,34 @@ Multi-pass Templating
341341
Embedding templates within other templates or expressions can result in untrusted templates being executed.
342342
The overhauled templating engine in this release no longer supports this insecure behavior.
343343

344+
Example - Unnecessary Template in Expression
345+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
346+
347+
This conditional references a variable using a template, instead of using the variable directly in the expression.
348+
349+
.. code-block:: yaml+jinja
350+
351+
- assert:
352+
that: 1 + {{ value }} == 2
353+
vars:
354+
value: 1
355+
356+
357+
The error reported is::
358+
359+
Syntax error in expression. Template delimiters are not supported in expressions: expected token ':', got '}'
360+
361+
362+
This can be resolved by referencing the variable without a template:
363+
364+
.. code-block:: yaml+jinja
365+
366+
- assert:
367+
that: 1 + value == 2
368+
vars:
369+
value: 1
370+
371+
344372
Example - Dynamic Expression Construction
345373
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
346374

0 commit comments

Comments
 (0)