HTML::MasonX::Free::Escape - default HTML escaping with an escape hatch
version 0.006
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:
html_hunk
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:
$flavor
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";
Ricardo Signes <rjbs@cpan.org>
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.
To install HTML::MasonX::Free, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::MasonX::Free
CPAN shell
perl -MCPAN -e shell install HTML::MasonX::Free
For more information on module installation, please visit the detailed CPAN module installation guide.