There is a difference between # and ? , although it is somewhat subtle and does not appear in your example.
? (exists): Checks the veracity of the given key. If the key is true, execute the body; otherwise, execute the body :else , if any.
# (section): Checks the veracity of this key. If the key is true, set the context in the key, and then execute the body. If the context is an array, execute the body once for each element of the array. If the key is not plausible, do not change contexts or execute the body :else if it exists.
So, if your template looked like this:
template:
{?values} {?.}true{:else}false{/.} {/values} {~n} {#values} {#.}true{:else}false{/.} {/values}
Then your result will be as follows:
true falsefalsefalsefalsefalsefalsetruetruetruetruetruetruetrue
The first line checks that values exist, but does not change the context. The second line checks for the current context (which in this case is the root context), and it prints true . Since ? does not go into the context and does not iterate over the array, true is printed only once.
smfoote
source share