5.3 updates

Sun, 07 May 2017 20:02:53 +0100

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 07 May 2017 20:02:53 +0100
changeset 6
219d7a7304f8
parent 5
7667b101cb1e
child 7
038275cd92ed

5.3 updates

config.lua file | annotate | diff | comparison | revisions
dependency.lua file | annotate | diff | comparison | revisions
err.lua file | annotate | diff | comparison | revisions
filecache.lua file | annotate | diff | comparison | revisions
handlers.lua file | annotate | diff | comparison | revisions
lgen.lua file | annotate | diff | comparison | revisions
log.lua file | annotate | diff | comparison | revisions
ltp/template.lua file | annotate | diff | comparison | revisions
luaext.lua file | annotate | diff | comparison | revisions
markdown.lua file | annotate | diff | comparison | revisions
path.lua file | annotate | diff | comparison | revisions
scan.lua file | annotate | diff | comparison | revisions
test.lua file | annotate | diff | comparison | revisions
time.lua file | annotate | diff | comparison | revisions
tuple.lua file | annotate | diff | comparison | revisions
--- a/ltp/template.lua	Sat Nov 01 23:34:21 2014 +0000
+++ b/ltp/template.lua	Sun May 07 20:02:53 2017 +0100
@@ -68,15 +68,19 @@
   return table.concat(result)
 end
 
-local function compile_template(data, start_lua, end_lua)
+local function compile_template_as_chunk(data, start_lua, end_lua)
+  local result = { "local output = ... " }
   return
-  table.concat(compile_template_to_table({ }, data, start_lua, end_lua))
+  table.concat(compile_template_to_table(result, data, start_lua, end_lua))
+end
+
+local function compile_template(data, start_lua, end_lua)
+  return table.concat(compile_template_to_table({ }, data, start_lua, end_lua))
 end
 
 local function load_template(data, start_lua, end_lua)
-  return
-  assert(loadstring(compile_template_as_function(data, start_lua, end_lua),
-                    "=(load)"))()
+  return assert(load(compile_template_as_chunk(data, start_lua, end_lua),
+                           "=(load)"))
 end
 
 local function execute_template(template, environment, output)
@@ -130,7 +134,7 @@
 
 local function execute_env_code(env_code, environment)
   for i = 1,#env_code do
-    local fun, emsg = loadstring(env_code[i])
+    local fun, emsg = load(env_code[i])
 
     if fun then
       setfenv(fun, environment)()
@@ -176,6 +180,7 @@
 return ltp.merge_table(
   {
     compile_template_to_table    = compile_template_to_table,
+    compile_template_as_chunk    = compile_template_as_chunk,
     compile_template_as_function = compile_template_as_function,
     compile_template             = compile_template,
     load_template                = load_template,
--- a/markdown.lua	Sat Nov 01 23:34:21 2014 +0000
+++ b/markdown.lua	Sun May 07 20:02:53 2017 +0100
@@ -186,7 +186,7 @@
 		local match = {s:find(p, index)}
 		if #match>0 and (#res==0 or match[1] < res[1]) then res = match end
 	end
-	return unpack(res)
+	return table.unpack(res)
 end
 
 -- If a replacement array is specified, the range [start, stop] in the array is replaced

mercurial