|
@@ -240,11 +240,17 @@ forms(File, Module, BodyAst, BodyInfo, CheckSum) ->
|
|
|
({XFile, XCheckSum}) ->
|
|
|
erl_syntax:tuple([erl_syntax:string(XFile), erl_syntax:string(XCheckSum)])
|
|
|
end, BodyInfo#ast_info.dependencies))])]),
|
|
|
-
|
|
|
+
|
|
|
+ BodyAstTmp = erl_syntax:application(
|
|
|
+ erl_syntax:atom(erlydtl_runtime),
|
|
|
+ erl_syntax:atom(stringify_final),
|
|
|
+ [BodyAst]
|
|
|
+ ),
|
|
|
+
|
|
|
RenderInternalFunctionAst = erl_syntax:function(
|
|
|
erl_syntax:atom(render2),
|
|
|
[erl_syntax:clause([erl_syntax:variable("Variables")], none,
|
|
|
- [BodyAst])]),
|
|
|
+ [BodyAstTmp])]),
|
|
|
|
|
|
ModuleAst = erl_syntax:attribute(erl_syntax:atom(module), [erl_syntax:atom(Module)]),
|
|
|
|
|
@@ -464,9 +470,13 @@ filter_ast(Variable, Filter, Context, TreeWalker) ->
|
|
|
|
|
|
filter_ast_noescape(Variable, [{identifier, _, "escape"}], Context, TreeWalker) ->
|
|
|
body_ast([Variable], Context, TreeWalker);
|
|
|
-filter_ast_noescape(Variable, [{identifier, _, Name} | Arg], Context, TreeWalker) ->
|
|
|
+filter_ast_noescape(Variable, Filter, Context, TreeWalker) ->
|
|
|
{{VariableAst, Info}, TreeWalker2} = body_ast([Variable], Context, TreeWalker),
|
|
|
- {{erl_syntax:application(erl_syntax:atom(erlydtl_filters), erl_syntax:atom(Name),
|
|
|
+ VarValue = filter_ast1(Filter, VariableAst),
|
|
|
+ {{VarValue, Info}, TreeWalker2}.
|
|
|
+
|
|
|
+filter_ast1([{identifier, _, Name} | Arg], VariableAst) ->
|
|
|
+ erl_syntax:application(erl_syntax:atom(erlydtl_filters), erl_syntax:atom(Name),
|
|
|
[VariableAst | case Arg of
|
|
|
[{string_literal, _, ArgName}] ->
|
|
|
[erl_syntax:string(unescape_string_literal(ArgName))];
|
|
@@ -474,8 +484,8 @@ filter_ast_noescape(Variable, [{identifier, _, Name} | Arg], Context, TreeWalker
|
|
|
[erl_syntax:integer(list_to_integer(ArgName))];
|
|
|
_ ->
|
|
|
[]
|
|
|
- end]), Info}, TreeWalker2}.
|
|
|
-
|
|
|
+ end]).
|
|
|
+
|
|
|
search_for_escape_filter(_, _, #dtl_context{auto_escape = on}) ->
|
|
|
on;
|
|
|
search_for_escape_filter(_, _, #dtl_context{auto_escape = did}) ->
|
|
@@ -490,6 +500,8 @@ search_for_escape_filter({apply_filter, Variable, Filter}, _) ->
|
|
|
search_for_escape_filter(_Variable, _Filter) ->
|
|
|
off.
|
|
|
|
|
|
+
|
|
|
+
|
|
|
resolve_variable_ast(VarTuple, Context) ->
|
|
|
resolve_variable_ast(VarTuple, Context, 'fetch_value').
|
|
|
|
|
@@ -509,7 +521,15 @@ resolve_variable_ast({variable, {identifier, _, VarName}}, Context, FinderFuncti
|
|
|
Val ->
|
|
|
Val
|
|
|
end,
|
|
|
- {VarValue, VarName}.
|
|
|
+ {VarValue, VarName};
|
|
|
+
|
|
|
+resolve_variable_ast({apply_filter, Variable, Filter}, Context, FinderFunction) ->
|
|
|
+ {VarAst, VarName} = resolve_variable_ast(Variable, Context, FinderFunction),
|
|
|
+ VarValue = filter_ast1(Filter, erl_syntax:list([VarAst])),
|
|
|
+ {VarValue, VarName};
|
|
|
+
|
|
|
+resolve_variable_ast(What, _Context, _FinderFunction) ->
|
|
|
+ error_logger:error_msg("~p:resolve_variable_ast unhandled: ~p~n", [?MODULE, What]).
|
|
|
|
|
|
resolve_scoped_variable_ast(VarName, Context) ->
|
|
|
lists:foldl(fun(Scope, Value) ->
|