Skip to content


Fix to the custom tags rendering #19

wants to merge 1 commit into from

4 participants


This fixes rendering tags from custom_tags_dir.

@alipiec alipiec Rendering custom tags improved
* rendering tags defined in custom_tags_dir directory fixed

The patch works. Thanks! Hope @evanmiller will merge it in!


Patch works for me, too. @evanmiller are there any problems with merging this?


The problem is that this fixes rendering of modules compiled with compile_dir, but breaks manually written modules which expect to be passed CustomTagsContext, not [{translation_fun, Fun}, {locale, Locale}, {custom_tags_context, CustomTagsContext}].

I am not certain but I think a proper solution will sneak some kind of marker into modules compiled with compile_dir which indicates they need to be passed the additional context. E.g. export a marker function or special attribute or something.


Any chance this will ever get done in order to fix the original issue? Or if it was possible to get a more detailed idea about what has to be done, may be I can contribute it...


Try this


@evanmiller evanmiller closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 4, 2012
  1. @alipiec

    Rendering custom tags improved

    alipiec committed
    * rendering tags defined in custom_tags_dir directory fixed
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/erlydtl_compiler.erl
7 src/erlydtl_compiler.erl
@@ -1120,11 +1120,11 @@ tag_ast(Name, Args, Context, TreeWalker) ->
custom_tags_modules_ast(Name, InterpretedArgs, #dtl_context{ custom_tags_modules = [], is_compiling_dir = false }) ->
{erl_syntax:application(none, erl_syntax:atom(render_tag),
- [erl_syntax:string(Name), erl_syntax:list(InterpretedArgs), erl_syntax:variable("CustomTagsContext")]),
+ [erl_syntax:string(Name), erl_syntax:list(InterpretedArgs), options_ast()]),
#ast_info{custom_tags = [Name]}};
custom_tags_modules_ast(Name, InterpretedArgs, #dtl_context{ custom_tags_modules = [], is_compiling_dir = true, module = Module }) ->
{erl_syntax:application(erl_syntax:atom(Module), erl_syntax:atom(Name),
- [erl_syntax:list(InterpretedArgs), erl_syntax:variable("CustomTagsContext")]), #ast_info{ custom_tags = [Name] }};
+ [erl_syntax:list(InterpretedArgs), options_ast()]), #ast_info{ custom_tags = [Name] }};
custom_tags_modules_ast(Name, InterpretedArgs, #dtl_context{ custom_tags_modules = [Module|Rest] } = Context) ->
case lists:member({Name, 2}, Module:module_info(exports)) of
true ->
@@ -1137,7 +1137,8 @@ custom_tags_modules_ast(Name, InterpretedArgs, #dtl_context{ custom_tags_modules
options_ast() ->
erl_syntax:tuple([erl_syntax:atom(translation_fun), erl_syntax:variable("TranslationFun")]),
- erl_syntax:tuple([erl_syntax:atom(locale), erl_syntax:variable("CurrentLocale")])
+ erl_syntax:tuple([erl_syntax:atom(locale), erl_syntax:variable("CurrentLocale")]),
+ erl_syntax:tuple([erl_syntax:atom(custom_tags_context), erl_syntax:variable("CustomTagsContext")])
call_ast(Module, TreeWalkerAcc) ->
Something went wrong with that request. Please try again.