diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-03-27 16:39:54 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-03-27 16:39:54 +0000 |
commit | 16f122266c71f8593026c16f14f91f913eec4e0d (patch) | |
tree | 54f3efef5a46ddeae176049cddaaf6598b419af8 | |
parent | 108d75cf1268062a8821bbbdc765e1a112b98b78 (diff) | |
download | rspamd-16f122266c71f8593026c16f14f91f913eec4e0d.tar.gz rspamd-16f122266c71f8593026c16f14f91f913eec4e0d.zip |
[Minor] Preserve line endings when templating
-rw-r--r-- | lualib/lua_util.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua index 0ae18a22e..d32058547 100644 --- a/lualib/lua_util.lua +++ b/lualib/lua_util.lua @@ -23,6 +23,7 @@ local exports = {} local lpeg = require 'lpeg' local rspamd_util = require "rspamd_util" local fun = require "fun" +local lupa = require "lupa" local split_grammar = {} local spaces_split_grammar @@ -30,6 +31,10 @@ local space = lpeg.S' \t\n\v\f\r' local nospace = 1 - space local ptrim = space^0 * lpeg.C((space^0 * nospace^1)^0) local match = lpeg.match +lupa.configure{ + keep_trailing_newline = true, + autoescape = false, +} local function rspamd_str_split(s, sep) local gr @@ -132,8 +137,6 @@ end -- "HELLO LUA WORLD!" --]] exports.jinja_template = function(text, env, skip_global_env) - local lupa = require "lupa" - if not skip_global_env then env = enrich_template_with_globals(env) end @@ -153,8 +156,6 @@ end -- "HELLO LUA WORLD!" --]] exports.jinja_template_file = function(filename, env, skip_global_env) - local lupa = require "lupa" - if not skip_global_env then env = enrich_template_with_globals(env) end |