RFC: template engine [ was: Re: Implementing tables - advice wanted ]

Torbjorn Tornkvist tobbe@REDACTED
Wed Jun 14 23:33:51 CEST 2006


Yariv Sadan wrote:
> Hi,
> 
>> Indeed, these four characteristics seem to be all we need and is in
>> line with mine and others' intuition that a template engine should
>> _not_ be a Turing complete language.
> 
> 
> I would like to bring up one more point in favor of using Erlang as a
> template language: ehtml. With an Erlang template language, you could
> write code such as
> 
> <%=
>       {ehtml, {table, [], {
>            lists:foldl(fun(E, A) ->
>                [{tr, [], {td, [{width, 20}], E#person.name}} | A]
>         end, [], dict:get(people, Data))}
>        }
>      },
> %>

Using the ehtml module in yfront (jungerl) you can write the 
above as:

{ehtml, ehtml:table([[E#person.name] || E <- 
dict:get(people,Data)])}

--Tobbe

> 
> in the template file. I think there's little doubt that this code does
> not belong in the controller, and that an ehtml tuple generated with
> pure Erlang is quite elegant.
> 
> My 2c.
> 
> Regards,
> Yariv
> 




More information about the erlang-questions mailing list