jinja arbitrary code expressions?

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,292
Messages
2,571,494
Members
48,171
Latest member
EllaHolmwo

Latest Threads

Top