N
Neal Becker
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)
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)