Hello, I'm currently working on a project using TurboGears2 with Jinja2 as the templating backend (merely preference), and digging trough the documentation I found nothing about how to make turbogears load Jinja extensions or custom filters, lurking at the source there seems to be no support for this at all!
Custom filters may be added at run time by getting the Jinja Environment class from the global config (config['pylons.app_globals'].jinja2_env), thus this piece of code should suffice to add a new filter somewhere in your code or configuration: from tg.configuration import config config['pylons.app_globals'].jinja2_env.filters['my_filter_name'] = filter_function Extensions gets trickier as you need to pass a list of modules to the Environment class when creating one, there is no simple way to add it latter, thus my solution was to subclass and re-implement the setup_jinja_renderer function and add the parameter extensions=[extension, list] to the Environment instantiation line. Currently my AppConfig subclass looks for configuration variable jinja_extensions to do the trick, also added a function to add a custom filter named add_jinja_filter, more interesting could be using a variable called jinja_filters and load the given modules function filters when setting jinja2 up but that's maybe for later. If anyone is interested in the code I added to a pastebin: http://pastebin.com/QXRH2S5F Would there be a chance of adding something like this to Turbogears for next revision?, I'm quite sure I could do a patch for it if people want it. Regards, Carlos Daniel Ruvalcaba Valenzuela -- You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en.

