Hi, all.

currently, render_jinja is not support Jinja2 i18n extension, maybe we
should improve it.
----
# original code
class render_jinja:
    """Rendering interface to Jinja2 Templates

    Example:

        render= render_jinja('templates')
        render.hello(name='jinja2')
    """
    def __init__(self, *a, **kwargs):
        from jinja2 import Environment,FileSystemLoader
        self._lookup = Environment(loader=FileSystemLoader(*a,
**kwargs))

    def __getattr__(self, name):
        # Assuming all templates end with .html
        path = name + '.html'
        t = self._lookup.get_template(path)
        return t.render
----

We should add 'extentions' and 'globals' in __init__ so that we can
use Jinja2 extensions:
----
from gettext import gettext as _

...skip some code here...
    def __init__(self, *a, **kwargs):
        from jinja2 import Environment,FileSystemLoader
        self._lookup = Environment(loader=FileSystemLoader(*a,
**kwargs), extensions=['jinja2.ext.i18n'])
        self._lookup.globals = {'_':_}
----

Template file:
----
{{ _('Hello') }} world.
----

Can we make 'render_jinja' accept 'extensions' while define render?

Thanks very much.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to