Templa...:TagSet(3pm)
π Template::Declare::TagSet β no wait, let's talk π
okay so bestie, this is the page for Template::Declare::TagSet, from the User Contributed Perl Documentation, and it's 3pm flavored, iykyk. Buckle up, we're building tag sets. π
β¨ NAME β¨
Template::Declare::TagSet β the base class for tag sets used by Template::Declare::Tags. It's giving "mom of all tag sets," fr fr. π
π¦ 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;
}
like, that's the whole vibe. copy it, love it, ship it. π
πΈ DESCRIPTION πΈ
So Template::Declare::TagSet is the base class for declaring packages of Template::Declare tags. If you need to make new tags for your templates, bestie, this is literally the base class for you!! π«Ά
Want a real one to stare at? Go review the source code of Template::Declare::TagSet::HTML β it's a genuinely useful example, no cap. π
β METHODS β
π new( PARAMS )
my $tag_set = Template::Declare::TagSet->new({
package => 'Foo::Bar',
namespace => undef,
});
Constructor created by Class::Accessor::Fast, and it accepts an optional hash reference of parameters. optional!! so chill. π
π get_tag_list
my $list = $tag_set->get_tag_list();
Returns an array ref for the tag names offered by a tag set. that's it, that's the method. simple. iconic. β¨
π get_alternate_spelling( TAG )
$bool = $obj->get_alternate_spelling($tag);
Returns true if a tag has an alternative spelling. Basically it's the workaround for naming conflicts β like, the girlies who refuse to share a name. π
For example: the tr tag in HTML conflicts with Perl's tr operator, and the template tag in XUL conflicts with the template sub exported by Template::Declare::Tags. messy, but we handle it. π
π can_combine_empty_tags( TAG )
$bool = $obj->can_combine_empty_tags($tag);
Specifies whether <tag></tag> can be combined into a single token, <tag />.
By default, all tags can be combined into a single token β override it in a subclass to change this value where appropriate.
For example:
Template::Declare::TagSet::HTML->can_combine_empty_tags('img')returns true, since<img src="..." />is always required for HTML pages. slay.Template::Declare::TagSet::HTML->can_combine_empty_tags('script'), on the other hand, returns false, since some browsers can't handle a single script token. π not the browsers being dramatic again.
π ACCESSORS π
This class has two read-only accessors. read-only, bestie, don't even try it. π«Ά
π package
my $package = $obj->package();
Retrieves the value of the package option set via the constructor.
π namespace
my $namespace = $obj->namespace();
Retrieves the value of the namespace option set via the constructor.
π§ AUTHOR π§
Agent Zhang <agentzh@yahoo.cn>. we stan. π
π₯ SEE ALSO π₯
Template::Declare::TagSet::HTMLTemplate::Declare::TagSet::XULTemplate::Declare::TagsTemplate::Declare
okay that's the whole page!! π
this was rendered with perl v5.34.0 and dated 2022-06-17, so that's the lore. go forth and tag set, bestie. periodt. πβ¨π¦
π¦ where this page comes from
- debian bookworm: libtemplate-declare-perl 0.47-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtemplate-declare-perl 0.47-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtemplate-declare-perl 0.47-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtemplate-declare-perl 0.47-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtemplate-declare-perl 0.47-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms