<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Practicality versus Purity for Python Templates</title>
	<link>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/</link>
	<description>Blog of Will McGugan</description>
	<pubDate>Sun, 07 Sep 2008 20:31:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: whity</title>
		<link>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18470</link>
		<dc:creator>whity</dc:creator>
		<pubDate>Fri, 29 Feb 2008 15:59:37 +0000</pubDate>
		<guid>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18470</guid>
		<description>I personally like Mako, because it's simple and they did not reinvented the wheel, allowing me to do some python if it's really needed.
I think there no better one, it depends on how you like to structure your work.</description>
		<content:encoded><![CDATA[<p>I personally like Mako, because it&#8217;s simple and they did not reinvented the wheel, allowing me to do some python if it&#8217;s really needed.<br />
I think there no better one, it depends on how you like to structure your work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Napoleone</title>
		<link>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18405</link>
		<dc:creator>Doug Napoleone</dc:creator>
		<pubDate>Fri, 29 Feb 2008 04:42:04 +0000</pubDate>
		<guid>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18405</guid>
		<description>@Dean:

Which template system completely strips the ability to put code in it?
Just curious.</description>
		<content:encoded><![CDATA[<p>@Dean:</p>
<p>Which template system completely strips the ability to put code in it?<br />
Just curious.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dean Landolt</title>
		<link>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18399</link>
		<dc:creator>Dean Landolt</dc:creator>
		<pubDate>Fri, 29 Feb 2008 03:31:16 +0000</pubDate>
		<guid>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18399</guid>
		<description>"We're all adults here" right? We all know not to put too much code in the templates, and most of us know why. But to completely strip the ability to do such a thing doesn't seem very pythonic to me.</description>
		<content:encoded><![CDATA[<p>&#8220;We&#8217;re all adults here&#8221; right? We all know not to put too much code in the templates, and most of us know why. But to completely strip the ability to do such a thing doesn&#8217;t seem very pythonic to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Napoleone</title>
		<link>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18387</link>
		<dc:creator>Doug Napoleone</dc:creator>
		<pubDate>Fri, 29 Feb 2008 01:09:11 +0000</pubDate>
		<guid>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18387</guid>
		<description>@Tim:

Question: why not separate out the data preparation logic into a separate file?
This would make things DRY in that the same presentation logic could be used for multiple preparations and the same preparation logic could be used for multiple presentations.

Granted, then you would have Django views and templates, where the templates are just the presentation layer consisting of 'a series of simple format, loop insert statements.' 

As for inventing your own restricted language there are MANY MANY reasons for doing so:

1. speed. 

It can be costly it allow for generic python code in a text file, as passing it off to be interpreted can be an added cost. this has to be weighed against the new language overheads of course.

2. complexity.

Complexity to debug. Complexity to optimize. Complexity to understand where things are happening. This can happen in any template system, but try debugging your generator expressions in a Genshi template, and you quickly go insane. (NOTE: Django is not much better here...) the rule is don't do anything more complex than simple looping and insertions in your templates, and put the complex stuff in your python irregardless of the template language. Why is the template language supporting all those complex operations again?

3. security

by restricting the command set in a template language you can add a level of security. many template languages use sand boxing and other systems for this (Neither Genshi nor Django do this, but it is a reason why people keep inventing new template languages)</description>
		<content:encoded><![CDATA[<p>@Tim:</p>
<p>Question: why not separate out the data preparation logic into a separate file?<br />
This would make things DRY in that the same presentation logic could be used for multiple preparations and the same preparation logic could be used for multiple presentations.</p>
<p>Granted, then you would have Django views and templates, where the templates are just the presentation layer consisting of &#8216;a series of simple format, loop insert statements.&#8217; </p>
<p>As for inventing your own restricted language there are MANY MANY reasons for doing so:</p>
<p>1. speed. </p>
<p>It can be costly it allow for generic python code in a text file, as passing it off to be interpreted can be an added cost. this has to be weighed against the new language overheads of course.</p>
<p>2. complexity.</p>
<p>Complexity to debug. Complexity to optimize. Complexity to understand where things are happening. This can happen in any template system, but try debugging your generator expressions in a Genshi template, and you quickly go insane. (NOTE: Django is not much better here&#8230;) the rule is don&#8217;t do anything more complex than simple looping and insertions in your templates, and put the complex stuff in your python irregardless of the template language. Why is the template language supporting all those complex operations again?</p>
<p>3. security</p>
<p>by restricting the command set in a template language you can add a level of security. many template languages use sand boxing and other systems for this (Neither Genshi nor Django do this, but it is a reason why people keep inventing new template languages)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Parkin</title>
		<link>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18386</link>
		<dc:creator>Tim Parkin</dc:creator>
		<pubDate>Fri, 29 Feb 2008 00:18:02 +0000</pubDate>
		<guid>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18386</guid>
		<description>Personally I'm coming to the conclusion that there should be two layers within a template. A data preparation layer and a presentation layer. The presentation layer should be a series of simple format, loop, insert statements. The data preparation layer should be pure python with tools. 

So a template becomes a combination of pure python and a simple xhtml template. I like Genshii in that it allows you to do this if you want. I like TAL like templates because they enforce a certain separation (but do we python programmers like enforced rules instead of conventions). The worst template language in my eyes is Django for it's creation of a new language (Why do template designers inist on recreating the wheel like that)</description>
		<content:encoded><![CDATA[<p>Personally I&#8217;m coming to the conclusion that there should be two layers within a template. A data preparation layer and a presentation layer. The presentation layer should be a series of simple format, loop, insert statements. The data preparation layer should be pure python with tools. </p>
<p>So a template becomes a combination of pure python and a simple xhtml template. I like Genshii in that it allows you to do this if you want. I like TAL like templates because they enforce a certain separation (but do we python programmers like enforced rules instead of conventions). The worst template language in my eyes is Django for it&#8217;s creation of a new language (Why do template designers inist on recreating the wheel like that)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Pipes</title>
		<link>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18381</link>
		<dc:creator>Jay Pipes</dc:creator>
		<pubDate>Thu, 28 Feb 2008 22:18:49 +0000</pubDate>
		<guid>http://www.willmcgugan.com/2008/02/28/practicality-versus-purity-for-python-templates/#comment-18381</guid>
		<description>I think this is a good question.  Personally, I think a balance of restricted functionality with a focus on presentation in the templates is the right way to go, but YMMV.</description>
		<content:encoded><![CDATA[<p>I think this is a good question.  Personally, I think a balance of restricted functionality with a focus on presentation in the templates is the right way to go, but YMMV.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
