NAME

Top Close Open

Template:TT3::Element::Delimiter - element for representing expression delimiters

DESCRIPTION

Top Close Open

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
    %]

METHODS

Top Close Open

This module implements the following methods in addition to those inherited from the Template::TT3::Element , Template::TT3::Base and Badger::Base base classes.

skip_delimiter($token)

Top Close Open

This method advances the element referenced by the $token variable past the current token and any subsequent whitespace or delimiter tokens.

parse_expr($token,$scope,$precedence)

Top Close Open

This method returns undef to indicate that a delimiter element does not yield an expression.

parse_body($token,$scope,$precedence)

Top Close Open

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.

view($view)

Top Close Open

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.

CONSTANTS

Top Close Open

The following constant method is defined.

FINISH

Top Close Open

This is defined as the literal keyword end and denotes the terminator token that indicates the end of a block. Subclasses may redefine this constant method to return a different keyword.

AUTHOR

Top Close Open

Andy Wardley http://wardley.org

COPYRIGHT

Top Close Open

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.

SEE ALSO

Top Close Open

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.


http://tt3.template-toolkit.org/docs/Template/TT3/Element/Delimiter.pm last modified 2009-12-21 15:28:45