Returns a Template::TT3::Type::Tree object representing the element tree of the parsed template. This is a thin wrapper around the block element returned by the block() method. The tree is cached internally
Returns a Template::TT3::Element::Block object representing the main block of a parsed template. This is generated by calling the parse() method. The block is cached internally once parsed.
This method parses the tokens returned by the tokens() method and returns a Template::TT3::Element::Block object representing the template expressions.
This returns a Template::TT3::Tokens
object representing the list of tokens
scanned from the template source. The tokens are generated by the
scan()
method and cached internally.
This method can be used to call another method with a try...catch
wrapper around it. Any errors caught are forwarded to the $handler
method.
The tree() , block() , scan() and various other public methods are implemented as thin wrappers around internal _tree() , _block() , _scan() , etc., methods. They use the catch() method something like this:
sub tree { my $self = shift; return $self->catch( decorate_error => _tree => @_ ); }
This calls the _tree()
method, passing all the arguments @_
that
were passed to the tree()
method. If an error is thrown then the
decorate_error()
method is called.
This method is called (typically by the catch() method) to decorate an exception object passed to it. It adds the template name to the exception and, if the error has a element token attached to, an extract of the template source where the error occurred. This allows the exception object to report a more useful error message.
The following methods are the internal implementations of their corresponding public methods (of the same name, but without the leading underscore). The public methods are wrappers around these internal methods that add some extra functionality for the purpose of better error reporting.
There's nothing to stop you from calling these methods directly but if you do then you won't get the template name and source extract added to the error message. If you're writing an internal method that will end up being wrapped in its own public method then you can and should call these methods directly. Otherwise you'll be invoking the catch handler twice (or more) for each error thrown.