NAME

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

VERSION

version 0.006

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";

AUTHOR

Ricardo Signes <rjbs@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 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.