This design document proposes that TT3 will use a context free grammar to parse keyword commands (what we generally refer to as 'directives' in TT2) as expressions. The end results is that keywords will be recognised anywhere that regular variables are recognised.
In TT2, directive keywords can only appear as the first word in a directive.
[% INCLUDE foo %]
There is one exception to this rule, where a directive keyword can appear on the right side of a top level assignment.
[% output = INCLUDE foo %]
However, this does not translate to any other positions where assignments or other expressions are permitted.
[% bar(INCLUDE foo) %] # FAIL in TT2 [% bar(output = INCLUDE foo) %] # FAIL in TT2
TT3 will recognise keywords in any position where variable are usually recognised.
[% bar(include foo) %] # OK in TT3 [% bar(output = include foo) %] # OK in TT3
Simplexity.
This change makes the language more general. Somewhat paradoxically, it makes the language (and underlying implementation) simpler, with fewer (or no) rules to remember about what tokens can appear where, while also making it more powerful and increasing the complexity of the constructs that can be expressed in it.
Conceptually, there is little or no breakage because keywords are not
permitted in non-keywords locations in TT2. However, when combined with
the fact that keywords are shifting to lower case by default for TT3 (see
TT3DD01), we have the
potential for a TT2 variable called include
being recognised
as a TT3 keyword.
# TT2 - call foo() passing the value in the include var [% foo(include) %] # TT3 - FAIL - missing template name(s) after 'include' [% foo(include) %]
However, this is an artefact of shifting keywords to lower case rather than anything specifically related to where the parser will recognise them.