Jesse Vincent > Template-Declare > Template::Declare::TagSet

Download:
Template-Declare-0.37.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  3
View/Report Bugs
Source   Latest Release: Template-Declare-0.47

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

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.

syntax highlighting: