> We create some custom scalar ops in a subclass of Catalyst::View::TT > (code below) that let you do: > > <select value="[% c.loc("Please select one").escape_dq %]">
Actually, escape_dq won't work here: <select value="[% c.loc("Please select one").escape_dq %]"> but it will work if for some reason you have a double-quote delimited JavaScript string. Will probably need to convert the double quotes to %22 instead. Sorry... > alert('[% c.loc("Please select one").escape_sq %]'); This one does work though... Larry > -------------------------------------------- > > package Platform::View::TT; > > # This is "MyApp/View/TT.pm": > > use strict; > use warnings; > > use base 'My::Catalyst::View::TT'; > > 1; > > -------------------------------------------- > > package My::Catalyst::View::TT; > > use strict; > use warnings; > > use base 'Catalyst::View::TT'; > > $Template::Stash::SCALAR_OPS->{escape_q} = sub { > my $s = shift; > $s =~ s/\\/\\\\/g; > $s =~ s/"/\\"/g; > $s =~ s/'/\\'/g; > return $s; > }; > > $Template::Stash::SCALAR_OPS->{escape_dq} = sub { > my $s = shift; > $s =~ s/\\/\\\\/g; > $s =~ s/"/\\"/g; > return $s; > }; > > $Template::Stash::SCALAR_OPS->{escape_sq} = sub { > my $s = shift; > $s =~ s/\\/\\\\/g; > $s =~ s/'/\\'/g; > return $s; > }; > > 1; > > -------------------------------------------- > > _______________________________________________ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/