[Catalyst] A couple (probably dumb) questions about TT

Dylan Vanderhoof DylanV at semaphore.com
Thu Sep 7 22:38:49 CEST 2006


This might not be the best list to ask on, but I'm subscribed, and
hopefully somebody will know the answers.  =)

First question, is it possible to deep-copy a structure using TT?  I
have a place where I'm taking a hashref from the stash, passing it as
args to the src of an img tag, and then changing a couple variables in
it before passing it to [% c.uri_for( /blah, new_args) %], but changing
a couple elements of new_args changes the same elements in args, as
designed.  Any way around this other than creating new_args as a new
hashref and copying the elements by name one by one?


Second question about encoding and javascript.  (Blah)  

One of the values in the above args hash is a title that may or may not
include a ' character.  It is displayed on the page fine, and passed to
things like the img src above correctly, but its also being used in a
call to <a href="#" onClick="javascript:window.open('[% c.uri_for(
/blah, args ) %]');"> (simplified, there's more to it than that, but
that's where the problem lies)  Unfortunatly, the ' character causes a
problem here, because its not quoted in any way and javascript barfs.
If I use [% args.title.replace( '\'', '%27' ) %], then the error goes
away, but I get exactly that in the params of the new window, and I'd
really like it unquoted when it hits Catalyst on the new window.

Any suggestions for how to get around this?  I'm sure its something
obvious, but I'm not coming up with anything miraculous.

Thanks,
Dylan



More information about the Catalyst mailing list