Here are some gotchmes and hopefully not gotchyous:
-
Don't write
loop.index > 0
as it will always be true;loop.index
is 1-indexed. Above, I needed the 0-indexed version:loop.index0
. 1 -
"If you want to assign a value in the global context while in a for loop, you must use set_global" 2
-
Don't forget to use
| safe
with trusted strings. 3 -
Underscores are ok in Tera macro names but hyphens are not. 4
Footnotes
-
Explained in https://keats.github.io/tera/docs/#for. ↩
-
Quoted from https://keats.github.io/tera/docs/#assignments except I changed the phrase "can use" to "must". ↩
-
From https://keats.github.io/tera/docs/#safe "Marks a variable as safe: HTML will not be escaped anymore. safe only works if it is the last filter of the expression" ↩
-
From https://github.com/Keats/tera/issues/913, valid characters are:
a-zA-Z_0-9
but cannot start with0-9
↩