jinja arbitrary code expressions?
Neal Becker
ndbecker2 at gmail.com
Wed Apr 29 20:09:57 EDT 2009
Can jinja templates contain arbitrary python code?
In mako, I could do (for example):
--------
from mako.template import Template
mytemplate = Template('''
<%!
from math import sin, pi
%>
hello ${name}!
${x}**2 = ${x**2}
% for i in xrange (10):
w[${i}] = ${sin (pi/4*i)}
% endfor
''')
d = {'name' : 'Neal',
'x' : 10
}
print mytemplate.render(**d)
--------
Could I do something similar in jinja? (import code, call arbitrary
functions...)
More information about the Python-list
mailing list