
On Apr 5, 2007, at 2:51 PM, David House wrote:
Why add another dependency, force your coders to learn another language, restrict yourself to a language which isn't as expressive as Haskell, reduce your ability to reuse code from different areas of the project and decrease project-wide consistency when you could just write your templates in Haskell to begin with?
Embedding code in web templates doesn't work well when you have designers on board. Let me elaborate on my approach as it doesn't reduce or restrict anything! I'm suggesting that you make your templates look like this, which is parseable as XML. Note the "tal:" tags. Please scroll through to the bottom for more thoughts. <?xml version="1.0" encoding="ISO-8859-1"?> <html> <head> <title tal:content="page/title">Page title</title> </head> <body> <h1 tal:content="page/title">Heading</h1> <p> Hello <b tal:omit-tag="visitor/humble"><span tal:replace="visitor/name">wo rld</span></b> </p> <p tal:condition="msg page/message" tal:content="msg">Message</p> <ul> <li>Hard-coded</li> <li tal:define="users page/users" tal:repeat="item users" tal:content="ite m/name">Dummy</li> </ul> <p tal:condition="page/renderfooter"> Back to <a href="#" tal:define="up page/up" tal:attributes="href up/ href;title up/ title">index</a> </p> </body> </html> The above expands into this: <html> <head> <title>Demo page</title> </head> <body> <h1>Demo page</h1> <p> Hello <b>Bruno</b> </p> <p>(c) 2006</p> <ul> <li>Hard-coded</li> <li>Xavier</li> <li>Damien</li> <li>Jacques</li> <li>Didier</li> <li>Jerome</li> </ul> <p> Back to <a title="Caml Home" href="http://caml.inria.fr/">index</a> </p> </body> </html> Note how <ul> <li>Hard-coded</li> <li tal:define="users page/users" tal:repeat="item users" tal:content="ite m/name">Dummy</li> </ul> is expanded to <ul> <li>Hard-coded</li> <li>Xavier</li> <li>Damien</li> <li>Jacques</li> <li>Didier</li> <li>Jerome</li> </ul> This is nice and _very_ clean and allows you to use any Haskell code you want to _process_ the template. You can, in fact, make template processing recursive and have tags produce more tags, i.e. make your components produce HTML instead of data for tags in the template. What do you think? -- http://wagerlabs.com/