is Jinja2 template translation possible?

15 views
Skip to first unread message

gordon

unread,
Nov 16, 2011, 3:20:36 PM11/16/11
to py2js mailinglist
Hi,

I am trying to find some way to have a template engine that can be run
from the server or the client using the same template source. Py2js
appears to be an option that will let me use my engine of choice. Is
py2js capable of compiling a jinja2 template to javascript?

Here is an example of a simple jinja2 template in python form:

~~~~~~~~~~~~~
from __future__ import division
from jinja2.runtime import LoopContext, TemplateReference, Macro,
Markup, TemplateRuntimeError, missing, concat, escape, markup_join,
unicode_join, to_string, identity, TemplateNotFound
name = u'foo.j2t'

def root(context, environment=environment):
l_a = context.resolve('a')
l_foo = context.resolve('foo')
if 0: yield None
yield u'%s\n%s' % (
environment.getattr(l_foo, 'bar'),
environment.getattr(environment.getattr(l_a, 'b'), 'c'),
)

blocks = {}
debug_info = '1=10&2=11'
~~~~~~~~~~~~~
Reply all
Reply to author
Forward
0 new messages