HTML::...LEscape(3pm)

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

✨ NAME ✨

HTML::Template::Compiled::Plugin::XMLEscape β€” it's giving XML-escaping for HTC, bestie πŸ’–


🌸 SYNOPSIS 🌸

use HTML::Template::Compiled::Plugin::XMLEscape;

my $htc = HTML::Template::Compiled->new(
    plugin => [qw(HTML::Template::Compiled::Plugin::XMLEscape)],
    ...
);

πŸ’… METHODS πŸ’…

  • register β€” HTC calls this one on its own, you don't gotta do anything 🫢
  • escape_xml β€” this is the one that escapes your data for XML CDATA ✨
  • escape_xml_attr β€” and this one escapes data for XML attributes, no cap πŸŽ€

🌈 EXAMPLE 🌈

okay so watch this, it's literally the whole vibe:

use HTML::Template::Compiled::Plugin::XMLEscape;
my $htc = HTML::Template::Compiled->new(
    plugin => [qw(HTML::Template::Compiled::Plugin::XMLEscape)],
    tagstyle => [qw(-classic -comment -asp +tt)],
    scalarref => \'<foo attr="[%= attribute %]">[%= cdata escape=XML %]</foo>',
    default_escape => 'XML_ATTR',
);
$htc->param(
    attr => 'foo & bar',
    cdata => 'text < with > tags',
);
print $htc->output;

⭐ Output ⭐

<foo attr="foo &amp; bar">text &lt; with &gt; tags</foo>

like… look at those ampersands and angle brackets getting fully handled. iconic behaviour fr fr πŸ”₯πŸ‘‘


that's the whole page, you ate it, periodt πŸ’œ

this little writeup came from the User Contributed Perl Documentation, riding along with perl v5.36.0, dated 2022-11-19 πŸ¦‹ β€” mwah, go escape something pretty πŸ’–

πŸ“¦ where this page comes from