[web-devel] A light-weight web framework
Maurice Codik
maurice.codik at gmail.com
Thu Apr 5 13:16:50 EDT 2007
>
> Embedding code in web templates doesn't work well when you have
> designers on board.
>
That's not necesarily true. Templates where there is mostly markup, but let
you embed code into them using special tags (ex, <% code %>) are extremely
popular and work fairly well. They also keep the template language simple
because there is already a full-powered programming language thats embedded
into it. Good examples of this method are ERB templates in Rails, JSPs, Perl
Mason templates, etc.
In these cases one of two things happen: either the designers learn enough
of the programming language to embed the right things in, or they just hand
off HTML to the developers, who can then replace the dynamic parts with <%
%> tags. If I'm a designer and I have learn a new templating language
anyway, I may as well just learn a little bit of
Haskell/Ruby/Perl/Java/whatever.
The best choice of templating technology really depends who the target
audience of the web framework is. Has there been much thought given to that
yet?
Maurice
On 4/5/07, Joel Reymont <joelr1 at gmail.com> wrote:
>
>
> 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/
>
>
>
>
>
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
>
--
http://blog.mauricecodik.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/web-devel/attachments/20070405/3a7d065f/attachment-0001.htm
More information about the web-devel
mailing list