++ed by:

2 PAUSE users
1 non-PAUSE user.

Shawn M Moore
and 1 contributors


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.

$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.

$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.


This class has two read-only accessors:


Retrieves the value of the package option set via the constructor.


Retrieves the value of the namespace option set by the constructor.


Agent Zhang <agentzh@yahoo.cn>.


Template::Declare::TagSet::HTML, Template::Declare::TagSet::XUL, Template::Declare::Tags, Template::Declare.