HTML::...LEscape(3pm)
β¨ 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 & bar">text < with > 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
- debian bookworm: libhtml-template-compiled-perl 1.003-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhtml-template-compiled-perl 1.003-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-template-compiled-perl 1.003-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-template-compiled-perl 1.003-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-template-compiled-perl 1.003-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