ings;
use strict;
use utf8;
use Carp;
our $VERSION = 'v2.0.1';
use Export::Attrs;
use JSON::XS qw( encode_json );
use URI::Escape qw();
use HTML::Entities qw();
use constant UNSAFE_HTML=> '&"\'<>'
xport {
my ($s) = @_;
if ($POST eq UTF8POST) {
$s = JSON::XS->new->encode($s);
} else {
$s = encode_json($s);
}
$s =~ s{</script}{<\\/script}xmsg;
return $s;
}
$complex );
Encode $complex data structure (HASHREF, ARRAYREF, etc. - any data type
supported by JSON::XS) for inserting into JavaScript code (usually inside
HTML templates).
Example:
<script>