gordon
unread,Nov 16, 2011, 3:20:36 PM11/16/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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'
~~~~~~~~~~~~~