Implementation details

56 views
Skip to first unread message

Jonns Mostovoys

unread,
Jun 19, 2012, 2:17:44 AM6/19/12
to erlydt...@googlegroups.com
Greetings, gentlemen.
I have a couple of questions —
1. is it possible to use unnamed arguments in custom tags? If 'yes' then how?
> {% f "42" %} as opposed to {% f x="42" %}
I have on the dtl side of things index_2.dtl template containing
> {% t "Test" %}
On the application side of things I try to make the following call
> erlydtl:compile("./site/templates/index_2.dtl", index_dtl, [{out_dir, "./site/ebin/"}, {custom_tags_modules, [saloon_lang]} %not doing it with rebar for a reason
And in the end I get the following parser error —
> site/src/saloon_main.erl:17:<0.5020.0>: erlydtl:compile: {error,{"./site/templates/index_2.dtl",
>                         [{{1,6},
>                           erlydtl_parser,
>                           ["syntax error before: ",["\"\\\"Test\\\"\""]]}]}}
When I change the template to
> {% t x="Test" %}
things begin to work :)
I thought that I should fix the grammar/AST generator myself, but fell into trying to trace the logics of machine-generated code,
and thus I'd be glad to hear about what am I doing wrong, what to do and where to lurk.

2. Wtf line 22 i18n/i18n_manager.erl? Was it tested? Why did it work?

3. Does anyone use {% trans ... %} feature? Is it me or its usage is currently a minefield (see 2.). If anybody uses  trans, please
share your workflow because I have little to none ideas how to interconnect Erlang's gettext equivalent with erlydtl.

Thank you gentlemen for replies,
honoured to use such a great open source product,
Jonn Mostovoy.

Evan Miller

unread,
Jun 19, 2012, 10:58:44 AM6/19/12
to erlydt...@googlegroups.com
Hello,
Arguments must be named at the moment. If you want to poke around the
grammar see

https://github.com/evanmiller/erlydtl/blob/master/src/erlydtl_parser.yrl

>
> 2. Wtf line 22 i18n/i18n_manager.erl? Was it tested? Why did it work?

This line?

https://github.com/evanmiller/erlydtl/blob/master/src/i18n/i18n_manager.erl#L22

Looks ok to me.

>
> 3. Does anyone use {% trans ... %} feature? Is it me or its usage is
> currently a minefield (see 2.). If anybody uses  trans, please
> share your workflow because I have little to none ideas how to interconnect
> Erlang's gettext equivalent with erlydtl.

See

https://github.com/evanmiller/erlydtl/blob/master/README_I18N

>
> Thank you gentlemen for replies,
> honoured to use such a great open source product,
> Jonn Mostovoy.



--
Evan Miller
http://www.evanmiller.org/

Jonns Mostovoys

unread,
Jun 19, 2012, 1:16:59 PM6/19/12
to erlydt...@googlegroups.com
Dear Evan,
thank you so much for the fast reply, as well as pointing me to the grammar file!
As for https://github.com/evanmiller/erlydtl/blob/master/src/i18n/i18n_manager.erl#L22
if I recall correctly string:tokens/ function returns the token list, not {ok, TokenList}.
Basically that made me think that trans functionality isn't used much in the modern erlydtl.
In either way I have already came up with my own translation module implementation :)
I'll have a look at possibility of implementation of unnamed args and post here in case of
success.

Thanks,
Jonn Mostovoy.


On Tuesday, 19 June 2012 17:58:44 UTC+3, Evan Miller wrote:
Hello,
Reply all
Reply to author
Forward
0 new messages