Browse Source

dtl compile auto_escape from settings (default false)

221V 1 year ago
parent
commit
0d8147f598
3 changed files with 12 additions and 1 deletions
  1. 1 0
      .gitignore
  2. 6 0
      README.md
  3. 5 1
      src/compile/mad_dtl.erl

+ 1 - 0
.gitignore

@@ -4,3 +4,4 @@ erl_crash.dump
 logs
 logs
 .mad.plt
 .mad.plt
 deps
 deps
+.applist

+ 6 - 0
README.md

@@ -57,6 +57,12 @@ Build
 
 
 And put `mad` to PATH.
 And put `mad` to PATH.
 
 
+add next code into your sys.config  
+for enable auto_escape option compiling erlydtl templates  
+```
+{mad, [{compile_dtl_escape, true}]},
+```
+
 BEAM Lightweight Unikernel Bundle
 BEAM Lightweight Unikernel Bundle
 ---------------------------------
 ---------------------------------
 
 

+ 5 - 1
src/compile/mad_dtl.erl

@@ -26,8 +26,12 @@ validate_erlydtl_opts(Cwd, Opts) ->
     DocRoot1 = {doc_root, filename:join(Cwd, DocRootDir)},
     DocRoot1 = {doc_root, filename:join(Cwd, DocRootDir)},
     {_, OutDir1} = OutDir,
     {_, OutDir1} = OutDir,
     OutDir2 = {out_dir, filename:join(Cwd, OutDir1)},
     OutDir2 = {out_dir, filename:join(Cwd, OutDir1)},
+    Auto_Escape = case application:get_env(mad, compile_dtl_escape, false) of
+      true -> {auto_escape, true};
+      _ -> {auto_escape, false}
+    end,
 
 
-    [DocRoot1, OutDir2, CompilerOpts, SourceExt, ModuleExt|Opts5].
+    [DocRoot1, OutDir2, CompilerOpts, Auto_Escape, SourceExt, ModuleExt|Opts5].
 
 
 module_name(File, Ext, NewExt) ->
 module_name(File, Ext, NewExt) ->
     list_to_atom(filename:basename(File, Ext) ++ NewExt).
     list_to_atom(filename:basename(File, Ext) ++ NewExt).