Login to your account |
Other Options |

There are a number of very powerful template languages available in Python. Some template languages, such as Genshi [genshi.edgewall.org], allow complex Python statements and even full Python code within the template file. Others, such as Django [djangoproject.com] templates, prefer to restrict templates to presentation only and do not allow general Python expressions within the body of the template.
In the context of a web framework, is it better to have the full expressiveness of Python, or restrict templates to presentation only?
NB. You can post code with the [code] bbcode tag. Many languages are supported. e.g.
[code python]
print "Hello, World!"
[/code]
Templates are Python programs to generate HTML output. Just because they provide a convenient syntax for outputting large blocks of text doesn't mean they should cripple the expressive power of the language. If I want to write a "for" loop in a template, why should I have to mark up a section of my template with some weird, custom tags, and then write the actual "for" loop somewhere else that's hard to find?
According to Lennart Regebro:
How do you mean that templates are python programs? You can't run them in a python interpreter...