NAME
Template::Declare::TagSet - Base class for tag set classes used by Template::Declare::Tags
SYNOPSIS
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;
}
METHODS
$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 thetr
operator in Perl and thetemplate
tag in XUL conflicts with thetemplate
sub exported byTemplate::Declare::Tags
. -
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.
ACCESSORS
This class has two read-only accessors:
$obj->package()
-
Retrieves the value of the
package
option set via the constructor. $obj->namespace()
-
Retrieves the value of the
namespace
option set by the constructor.
AUTHOR
Agent Zhang <agentzh@yahoo.cn>.
SEE ALSO
Template::Declare::TagSet::HTML, Template::Declare::TagSet::XUL, Template::Declare::Tags, Template::Declare.