The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::MasonX::Free::Escape - default HTML escaping with an escape hatch

VERSION

version 0.007

OVERVIEW

First, when you set up your compiler, you pass:

  default_escape_flags => 'html'

Then, when you set up your interpreter, you redefine the html handler(s):

  use HTML::MasonX::Free::Escape qw(html_escape);
  $interp->set_escape('h' => \&html_escape);
  $interp->set_escape('html' => \&html_escape);

Finally, for good measure, get html_hunk imported to your Commands package:

  package HTML::Mason::Commands { use HTML::MasonX::Free::Escape 'html_hunk' }

Now, by default, when you do this in a template:

  The best jelly is <% $flavor %> jelly.

...the $flavor will be HTML entity escaped. If you want to deal with variables that are not going to be escaped, you use html_hunk:

  Here's some math: <% html_hunk( $eqn->as_mathml ) %>

Even though it's called html_hunk, it just means "don't HTML escape this." If you put in some XML, you won't get in trouble. The result of calling html_hunk is an object that will throw an exception if stringified. This prevents you from making mistakes like:

  my $target = html_hunk("world");
  my $greet  = "Hello, $target";

PERL VERSION

This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.

Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.

AUTHOR

Ricardo Signes <cpan@semiotic.systems>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Ricardo Signes.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.