[erlang-questions] A simple gen_server to rebuild dtl templates [Was: What's the recommended template engine for web development with erlang?]

Liu Yubao yubao.liu@REDACTED
Wed Feb 4 02:45:52 CET 2009


Christian wrote:
>> * erldtl
>>
>>  Pros: The template notation seems good(I hate <newtag> and <%...%> :-)
>>        templates are compiled to erlang modules;
>>  Cons: not completed yet.
> 
> What is a show-stopper for you about erlydtl? What is not complete
> enough for you?
> 
> The features I use, they work well.
> 
> I'm about to get annoyed enough with rebuilding all template modules
> each time i run make that i am ready to add something that only builds
> the templates that have changed or use dependencies that have changed.
> But other than that, it works fine.
> 
I wrote a little gen_server to rebuild template files, maybe you'll be
interested in it, below is the usage:

hello.yaws:
  <erl>
  out(Arg) ->
      M = dtl_server:lookup("path/to/hello.dtl"),
      {ok, L} = M:render(),
      {html, L}.
  </erl>

Accessing http://your-host/path/to/dtlmake.yaws to rebuild template files
that are changed (or their dependencies change) *and* lookuped at least
one time. The dtl:lookup/1 will compile the template for the first time.

To use this little server, a patch to erlydtl may be required, see attachments
for all related files, there is a simple explanation in the patch.

Best regards,
Liu Yubao


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: erlydtl_compiler.patch
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090204/ac191fd8/attachment.ksh>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090204/ac191fd8/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dtl_server.erl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090204/ac191fd8/attachment-0001.ksh>


More information about the erlang-questions mailing list