[Petal] control over encoding
Jonathan Vanasco
jon at 2xlp.com
Thu Jul 27 15:30:25 BST 2006
On Jul 27, 2006, at 2:37 AM, Benjamin Tucker wrote:
> 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.
Teach your people to use 'structure' when they want HTML and not when
they don't-- because that distinction is in the TAL specification,
which means your hack is Petal specific, and your templates worthless
with any other implementatino
More information about the Petal
mailing list