https://github.com/clsdaniel/tg2-jinja2-updates
git://github.com/clsdaniel/tg2-jinja2-updates.git
I'm just starting with the patches, but if there is comments or
feature requests (related to jinja2 support) drop me a mail or and
issue on github.
So far I just added support for loading extensions and simple filters
along with test cases (which also pass), I'll be adding more as I have
time (or need), I try to follow upstream repository on sourceforge
too.
Regards,
Carlos Ruvalcaba
Should we have a special place where you can code custom filters and
extensions and have it loaded automatically if the Jinja2 renderer is
chosen (like django extensions/filters)?
If so, where would be the best place to put this? on lib?, maybe I can
make the loader look up at lib for extensions.py and filters.py, or
have a special directory for them?, currently django has a directory
called templatetags for this, we could have one in lib/
This special folder would not come with the main turbogears paster
template (it doesn't come with default django setup either), the user
would have to create it and add its files, the jinja2 renderer would
look it up and if available load it, otherwise load the given filters
and extensions from config, we could even have a config option to
disable auto_loading.
I also forked the tg2docs from Michael on github, but would like to
nail this first before updating the docs.
Regards,
Carlos Ruvalcaba
PD: Posting this to main turbogears list to poll users.
Done
> I think that for extenions they are better managed in the configuration
> file.
> Filters, instead, might be a good candidate for being included in the
> project and automatically loaded as I see them more related to helpers.
> If we really want to do this we might consider creating a lib.something
> module and handle all the template related extensions and functions there.
> So that we will have lib.something.helpers, lib.something.jinja_filters,
> lib.something.whatever and people know that for any template filter, helper
> etc they can look there.
> I just don't have any idea on how "lib.something" should be called, but I
> think that it is better than putting everything in lib alone which might
> bring us to have lib.this, lib.that, lib.future_idea caos.
I don't really see people creating many custom extensions for each
project, filters are more common.
The thing is that helpers are loaded to the template context, be it
variables, data or functions, filters in the other hand are functions
too, they have a very specific function and way of working, in the end
they more of a syntaxis thing for the template, they are functions
that will always accept at least 1 value and do something and return a
value, thus they have some overlap with helper functions.
Maybe we could have a lib.templates?, thus we would end up with
lib.templates.helpers and lib.templates.jinja_filters.
Regards,
Carlos Ruvalcaba