Template::Declare::TagSet - Base class for tag set classes used by Template::Declare::Tags
package My::TagSet; use base 'Template::Declare::TagSet'; # returns an array ref for the tag names sub get_tag_list { [ qw/ html body tr td table base meta link hr / ] } # prevents potential naming conflicts: sub get_alternate_spelling { my ($self, $tag) = @_; return 'row' if $tag eq 'tr'; return 'cell' if $tag eq 'td'; } # Specifies whether "<tag></tag>" can be # combined to "<tag />": sub can_combine_empty_tags { my ($self, $tag) = @_; $tag =~ /^ base | meta | link | hr $/x; }
$obj = Template::Declare::TagSet->new({ package => 'Foo::Bar', namespace => undef });
Constructor created by Class::Accessor::Fast, accepting an optional option list.
Class::Accessor::Fast
$list = $obj->get_tag_list()
Returns an array ref for the tag names.
$bool = $obj->get_alternate_spelling($tag)
Returns whether a tag has an alternative spelling. Basically it provides a way to work around naming conflicts, for examples, the tr tag in HTML conflicts with the tr operator in Perl and the template tag in XUL conflicts with the template sub exported by Template::Declare::Tags.
tr
template
Template::Declare::Tags
$bool = $obj->can_combine_empty_tags($tag)
Specifies whether "<tag></tag>" can be combined into a single token "<tag />".
Always returns true (value 1) in this base class.
But there's some cases where you want to override the deafault implementation. For example, Template::Declare::TagSet::HTML->can_combine_empty_tags('img') returns true (1) since <img src="..." /> is always required for HTML pages.
Template::Declare::TagSet::HTML->can_combine_empty_tags('img')
<img src="..." />
This class has two read-only accessors:
$obj->package()
Retrieves the value of the package option set via the constructor.
package
$obj->namespace()
Retrieves the value of the namespace option set by the constructor.
namespace
Agent Zhang <agentzh@yahoo.cn>.
Template::Declare::TagSet::HTML, Template::Declare::TagSet::XUL, Template::Declare::Tags, Template::Declare.
To install Template::Declare, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Declare
CPAN shell
perl -MCPAN -e shell install Template::Declare
For more information on module installation, please visit the detailed CPAN module installation guide.