On Fri, Jan 9, 2009 at 2:38 AM, mk <[email protected]> wrote: > > cropr wrote: >> I don't know if you are using Mako templates, but if you do, you can >> always use the a filter like >> ${ any_python_function() | n} > > Thanks, that worked! > > Is there a way to make it default behavior?
It sounds like you're using the unwrapped version of the deprecated Rails helpers. Change "from webhelpers.rails import *" in myapp/lib/helpers.py to "from webhelpers.rails.wrapped import *". This wraps all return values in literal() (See webhelpers/html/builders.py), which prevents them from being escaped by the Pylons-Mako filter. Even better is to move away from the rails helpers to webhelpers.html, webhelpers.text, etc. But if that means making changes throughout the application you can do it gradually. The "| n" flag disables the default filter, which is why it works. The default filter is set somewhere in render_mako() in pylons.templating, or in myapp.config.environment . If you create a template variable value in Python with embedded HTML markup that you don't want to be escaped, you also have to wrap it in literal() (preferred) or use "| n". Better to mark it as literal as soon as you know it's trusted markup (and not possibly malicious user input). -- Mike Orr <[email protected]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
