Templa...:TagSet(3pm)

πŸ“¦
version 0.47 Β· 2 versions
  • 0.47 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.47 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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::HTML
  • Template::Declare::TagSet::XUL
  • Template::Declare::Tags
  • Template::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