This module implements a thin subclass of Template::TT3::Element::Literal to represent synthesised padding tokens (usually whitespace) that are inserted into the parsed token stream as part of the parsing process.
For example, the =
pre and post chomp flags collapse any preceding or
following text to a single space. Consider the following example:
foo [%= 'bar' =%] baz
The two blocks of four spaces surrounding the inline tag are added to the token stream as whitespace tokens. Whitespace tokens do not generate any output when the template is evaluated. However, we keep them in the token stream in case we want to regenerate the original template source (e.g. for debugging, error reporting, transforming the template, etc). At this point, the template would be rendered as if it was written:
foo[% 'bar' %]baz
The =
chomp option creates Template::TT3::Element::Padding
elements
comprised of a single space. These are injected into the token stream on
either side of the inline tag. Padding elements do yield their values
when the template is evaluated. So the output generated from the template
is:
foo bar baz
And all is good.
This module implements the following method in addition to those inherited from the Template::TT3::Element::Literal , Template::TT3::Element , Template::TT3::Base and Badger::Base base classes.
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_padding()
method against the view object passed as the only
argument, $view
. It passes itself as an argument to the view_padding()
method.
The following constant method is defined:
This defines a sprintf()
format string of "%s"
(note that the quotes
are part of the format). This is used by the
source()
method inherited from
Template::TT3::Element::Literal
to render a canonical representation
of the template source code for this element.
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::Literal , Template::TT3::Element , Template::TT3::Base and Badger::Base base classes.
It is constructed using the Template::TT3::Class::Element class metaprogramming module.