Template:TT3::Element::Delimiter - element for representing expression delimiters
This module implements a subclass of Template::TT3::Element to represent expression delimiters. It also acts as a base class for the Template::TT3::Element::TagEnd module.
Delimiters are comprised of the end-of-tag tokens, e.g. %], ?], etc.,
and also semi-colons used to delimit separate statements inside a single
tag:
[% if foo %]
... ^delimiter
[% end %]
[% if foo;
... ^ delimiter
end
%]
This module implements the following methods in addition to those inherited from the Template::TT3::Element , Template::TT3::Base and Badger::Base base classes.
This method advances the element referenced by the $token variable past
the current token and any subsequent whitespace or delimiter tokens.
This method returns undef to indicate that a delimiter element does not
yield an expression.
This method is called when a keyword expects a block argument. If a delimiter
follows where a block is expected then it is assumed that the block continues
until a corresponding end token (a
terminator
token, not to be confused with
a cyborg sent from the future to kill Sarah Connor).
[% if foo %]
... ^delimiter starts block
[% end %]
^terminator ends block
[% if foo;
... ^delimiter starts block
end
%] ^terminator ends block
It parses a block of content, checks that the terminator token is end,
and also, if any fragment is defined that it corresponds to the keyword
opening the block.
[% if foo;
...
end#if
%]
The opening keyword may also have a fragment defined.
%% for#outer x in X
%% for#inner y in Y
...
%% end#inner
%% end#outer
If a fragment is specified for an end token then it must match the
keyword (e.g. if, for, etc), or the fragment name specified with
the keyword, if there is one (e.g. outer and inner in the above
example). Otherwise a syntax error will be thrown.
This method is called by a
Template::TT3::View
object as part of the double
dispatch process that is used to render views of template elements. It calls
the view_delimiter() method against the view object passed as the only
argument, $view. It passes itself as an argument to the
view_delimiter() method.
Andy Wardley http://wardley.org
Copyright (C) 1996-2009 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This module inherits methods from the Template::TT3::Element , Template::TT3::Base and Badger::Base base classes.
It is constructed using the Template::TT3::Class::Element class metaprogramming module.
It is the base class for the Template::TT3::Element::TagEnd module.