NAME

Top Close Open

Template:TT3::Element::Padding - element representing padding tokens

DESCRIPTION

Top Close Open

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.

METHODS

Top Close Open

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.

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

CONSTANTS

Top Close Open

The following constant method is defined:

SOURCE_FORMAT

Top Close Open

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.

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::Literal , Template::TT3::Element , Template::TT3::Base and Badger::Base base classes.

It is constructed using the Template::TT3::Class::Element class metaprogramming module.


http://tt3.template-toolkit.org/docs/Template/TT3/Element/Padding.pm last modified 2009-12-20 12:08:54