NAME

Top Close Open

Template:TT3::Element::Terminator - element for representing terminator tokens

DESCRIPTION

Top Close Open

This module implements a subclass of Template::TT3::Element to represent various terminator tokens. It also acts as a base class for the Template::TT3::Element::End module.

Terminators are used to deliberately break the flow of the expression parser. For example, the end token at the end of a template block is used to tell the parse "Hey, stop that! We've run out of expressions. I'm special!". Terminator tokens are also to indicate the end of data constructs such as the ], } and ) tokens used for the end of list definitions, hash definitions and parameter lists, respectively. Again, they are used as hard markers to indicate the end of a sequence of expressions.

Terminator tokens are usually only ever consumed by the corresponding token that began a block. For example, the [ token indicates the start of a list. The parse_expr() method for that element calls the parse_body() method on the next token. This will consume expressions until the next terminator token and then return the block of expressions parsed. At this point the $token reference will be pointing at the unconsumed terminator token. The method can check that the terminator token is correct (e.g. is ] to match the opening [) and raise a syntax error if that is not the case.

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.

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 returns undef to indicate that a delimiter element does not yield a body of expressions.

parse_infix($lhs,$token,$scope,$precedence)

Top Close Open

This method is an alias to the reject() method inherited from the Template::TT3::Element base class. It is called by a preceding expression to give infix operators the opportunity to contribute to expression generated. Terminators are mean old gits that don't like to contribute anything, so they simply return the expression on the left of the terminator, passed to the method as the $lhs argument.

terminator()

Top Close Open

An alias to the next_skip_ws() method inherited from Template::TT3::Element .

TODO: I don't think this is used any more.

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_terminator() method against the view object passed as the only argument, $view. It passes itself as an argument to the view_terminator() method.

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::End module.


http://tt3.template-toolkit.org/docs/Template/TT3/Element/Terminator.pm last modified 2009-12-20 14:14:10