How do web templates separate content and logic?
Sebastian "lunar" Wiesner
basti.wiesner at gmx.net
Fri Jun 27 12:21:26 EDT 2008
John Salerno <johnjsal at NOSPAMgmail.com>:
> But when you have a templating system that mixes HTML and Python code, how
> is this helping to keep things separate?
You don't. Normally you embed only the code, that is absolutely necessary,
e.g. for iterating over a list.
Consider an online shop, that needs to do display a list of articles.
Inside the template, you would iterate over a list of and query attributes
of "Article" object to render the information as HTML. You would _not_
create a database connection, parse search parameters, find matching
articles and create a list of them. That's the job of the controller
inside the web app.
--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
More information about the Python-list
mailing list