Re: How do web templates separate content and logic?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sebastian \lunar\ Wiesner

    Re: How do web templates separate content and logic?

    John Salerno <johnjsal@NOSPA Mgmail.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)
Working...