Ksenia Marasanova wrote:
I am looking for fast, simple templating system that will allow me to do the following: - embed Python code (or some templating code) in the template - generate text output (not only XML/HTML)
I don't need a framework (already have it), but just simple templating. The syntax I had in mind is something like that:
# in Python module def some_view(): # some code goes here... records = get_some_data() req = get_request_class() return template('some_template.tmpl', **locals()).render()
# in some_template.tmpl:
<ul> <%for record in records%> <li><a href="<%=record.id%>"><%=record.title%></a></li> <%end for%> </ul>
From what I saw Cheetah seems to be the only one that can do it. I washoping there might be alternatives that I've missed :) Thanks!
EmPy will also do this quite handily:
http://www.alcyone.com/software/empy/
In EmPy, your template would look something like this::
<ul> @[for record in records]@ <li><a href="@record.id">@record.title</a></li> @[end for]@ </ul>
Batch expanding the template would look like something as simple as (substituting in your example)::
... return em.expand(open(templateFilename).read(), **locals())
-- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis There's this perfect girl / Someone no one can see -- Lamya -- http://mail.python.org/mailman/listinfo/python-list