is
is the new = block
[% message = block %] Hello [% name or 'World' %]! [% end %] [% message is %] Hello [% name or 'World' %]! [% end %] --EOF--look inside...
Thus Spake Andy:
All commands are expressions. There are no statements in TT3 (in the sense that it's used in programming language theory - if you're not familiar with the difference between a statement and expression then don't worry, you can skip this explanation). "Statements" in TT3 are simply expressions that don't yield any values (like Ruby). But as far as the parser is concerned, everything is an expression and you can assign the output of any expression to a variable, pass it to a function, etc.
The block
command can be used to create named blocks in a statement-like
way, as we saw in the previous example. The first example on this page
shows it being used as an inline expression to simply delineate a block
of content. Everything between block
and end
is evaluated and assigned
to the message
variable. You could do this in TT2, but it was a dedicated
parser hack. In TT3 this is built into the language and it Just Works™
for every command/expression.
The assignment operator =
expects an expression on it's right hand side.
The block
command effectively takes a block of content and "makes it" an
expression for the assignment to use. The is
command rolls these two
fundamental operations into one. It's essentially a block-oriented version
of =
.