27 Jul 08:37
control over encoding
Hi all, I'm new to Petal and the list, so I apologize if this is something that's been discussed before. I spent the better part of today integrating Petal into a mod_perl-based CMS. All went very well with one exception. There are a number of methods I had wanted to expose to the templates which return HTML. Of course Petal helpfully encodes them. I know that it provides the 'structure' keyword to turn this off, but I didn't want template authors to be forced to think about it, and rather wanted control from the data side of when escaping should not occur. So my solution was I changed all the exposed methods that returned HTML to return the string as a scalar ref. next I changed Petal::Hash::Var::process to not dereference scalar refs. then I added to Petal::Hash::get_encoded logic not to not encode if $res is a scalar reference, and then dereferences $res. (see attached patches). Will this break anything? is Petal::Hash::Var::process ever accessed without going through Petal::Hash::get_encoded? Does anyone have a suggestion of a better solution. Thanks! Ben
RSS Feed