|
@@ -85,8 +85,8 @@ compile(File, DocRoot, Module, Function, OutDir) ->
|
|
{module, _} -> ok;
|
|
{module, _} -> ok;
|
|
_ -> {error, "code reload failed"}
|
|
_ -> {error, "code reload failed"}
|
|
end;
|
|
end;
|
|
- _ ->
|
|
+ {error, Reason} ->
|
|
- {error, "beam generation failed"}
|
|
+ {error, lists:concat(["beam generation failed (", Reason, "): ", Path])}
|
|
end;
|
|
end;
|
|
_ ->
|
|
_ ->
|
|
{error, "compilation failed"}
|
|
{error, "compilation failed"}
|
|
@@ -160,7 +160,7 @@ body_ast(DjangoAst, Context) ->
|
|
({'text', _Pos, String}) ->
|
|
({'text', _Pos, String}) ->
|
|
erl_syntax:string(String);
|
|
erl_syntax:string(String);
|
|
({'string_literal', _Pos, String}) ->
|
|
({'string_literal', _Pos, String}) ->
|
|
- erl_syntax:string(unescape_string_literal(String));
|
|
+ auto_escape(erl_syntax:string(unescape_string_literal(String)), Context);
|
|
({'number_literal', _Pos, Number}) ->
|
|
({'number_literal', _Pos, Number}) ->
|
|
erl_syntax:string(Number);
|
|
erl_syntax:string(Number);
|
|
({'variable', Variable}) ->
|
|
({'variable', Variable}) ->
|
|
@@ -235,11 +235,13 @@ search_for_escape_filter(_Variable, _Filter) ->
|
|
off.
|
|
off.
|
|
|
|
|
|
resolve_variable_ast({{identifier, _, VarName}}, Context) ->
|
|
resolve_variable_ast({{identifier, _, VarName}}, Context) ->
|
|
- resolve_variable_name_ast(VarName, Context);
|
|
+ auto_escape(resolve_variable_name_ast(VarName, Context), Context);
|
|
|
|
|
|
resolve_variable_ast({{identifier, _, VarName}, {identifier, _, AttrName}}, Context) ->
|
|
resolve_variable_ast({{identifier, _, VarName}, {identifier, _, AttrName}}, Context) ->
|
|
- erl_syntax:application(erl_syntax:atom(proplists), erl_syntax:atom(get_value),
|
|
+ auto_escape(erl_syntax:application(
|
|
- [erl_syntax:atom(AttrName), resolve_variable_name_ast(VarName, Context)]).
|
|
+ erl_syntax:atom(proplists), erl_syntax:atom(get_value),
|
|
|
|
+ [erl_syntax:atom(AttrName), resolve_variable_name_ast(VarName, Context)]),
|
|
|
|
+ Context).
|
|
|
|
|
|
resolve_variable_name_ast(VarName, Context) ->
|
|
resolve_variable_name_ast(VarName, Context) ->
|
|
VarValue = lists:foldl(fun(Scope, Value) ->
|
|
VarValue = lists:foldl(fun(Scope, Value) ->
|
|
@@ -250,19 +252,21 @@ resolve_variable_name_ast(VarName, Context) ->
|
|
Value
|
|
Value
|
|
end
|
|
end
|
|
end, undefined, Context#dtl_context.local_scopes),
|
|
end, undefined, Context#dtl_context.local_scopes),
|
|
- VarValue1 = case VarValue of
|
|
+ case VarValue of
|
|
undefined ->
|
|
undefined ->
|
|
erl_syntax:application(erl_syntax:atom(proplists), erl_syntax:atom(get_value),
|
|
erl_syntax:application(erl_syntax:atom(proplists), erl_syntax:atom(get_value),
|
|
[erl_syntax:atom(VarName), erl_syntax:variable("Variables")]);
|
|
[erl_syntax:atom(VarName), erl_syntax:variable("Variables")]);
|
|
_ ->
|
|
_ ->
|
|
VarValue
|
|
VarValue
|
|
- end,
|
|
+ end.
|
|
|
|
+
|
|
|
|
+auto_escape(Value, Context) ->
|
|
case Context#dtl_context.auto_escape of
|
|
case Context#dtl_context.auto_escape of
|
|
on ->
|
|
on ->
|
|
erl_syntax:application(erl_syntax:atom(erlydtl_filters), erl_syntax:atom(force_escape),
|
|
erl_syntax:application(erl_syntax:atom(erlydtl_filters), erl_syntax:atom(force_escape),
|
|
- [VarValue1]);
|
|
+ [Value]);
|
|
_ ->
|
|
_ ->
|
|
- VarValue1
|
|
+ Value
|
|
end.
|
|
end.
|
|
|
|
|
|
ifelse_ast(Variable, IfContentsAst, ElseContentsAst, Context) ->
|
|
ifelse_ast(Variable, IfContentsAst, ElseContentsAst, Context) ->
|