[erlang-questions] parameterized modules alternative in chicago boss like use case

Pablo Platt pablo.platt@REDACTED
Mon Jul 4 17:32:31 CEST 2011


proplist will work but it won't allow me to do cool tricks
like define a field value that instructs the erlydtl tag to auto load child models.
For example, if we have the following record:

{group_product, {"my-group-product", 15, 100, {#load, children, 15}}
We might have a tag that knows how to load child products from the db.

I'm trying to use exprecs as you suggested with a custom erlydtl tags module.

The module:

-module(mytags).
-export([mytag/2]).
mytag(Variables, RenderOptions) ->
    io:format("~p~n", [Variables]),
    io:format("~p~n", [RenderOptions]),
    ["test"].

Template:
{% mytag %}

Compile with:

erlydtl:compile("test.dtl", "test_dtl", [{out_dir, "./"}, {custom_tags_module, "mytags"}]).

I don't understand how to pass arguments to the tag and how to have something like
{% for a in l %} {{ a.attr }} {% endfor %}







----- Original Message -----
From: Tim Watson <watson.timothy@REDACTED>
To: Pablo Platt <pablo.platt@REDACTED>
Cc: "erlang-questions@REDACTED" <erlang-questions@REDACTED>
Sent: Monday, July 4, 2011 4:27 PM
Subject: Re: [erlang-questions] parameterized modules alternative in chicago boss like use case

On 4 July 2011 12:12, Pablo Platt <pablo.platt@REDACTED> wrote:
> exprecs looks interesting.
> Not sure how hard it will be to patch erly_dtl to use it.
>

Actually come to think of it, erlydtl will take a proplist. So with
exprecs, you can work (in your code) with a record and then use the
(auto) exported exprecs functions to convert this to a property list.
I do something similar to this (for serialization purposes) here:
https://github.com/hyperthunk/nodewatch/blob/master/dxcommon/src/dxcommon.erl#L46




More information about the erlang-questions mailing list