Diff

util/template.lua @ 7197:ff514c1b1c27

util.template: Use separate variables for source and compiled function [luacheck]
author Kim Alvefur <zash@zash.se>
date Thu, 25 Feb 2016 22:32:13 +0100
parent 7196:94ec474debf5
child 8418:ad1e10c93b41
line wrap: on
line diff
--- a/util/template.lua	Thu Feb 25 22:31:13 2016 +0100
+++ b/util/template.lua	Thu Feb 25 22:32:13 2016 +0100
@@ -67,12 +67,12 @@
 local function create_cloner(stanza, chunkname)
 	local lookup = {};
 	local name = create_clone_string(stanza, lookup, "");
-	local f = "local setmetatable,stanza_mt=...;return function(data)";
+	local src = "local setmetatable,stanza_mt=...;return function(data)";
 	for i=1,#lookup do
-		f = f.."local _"..i.."="..lookup[i]..";";
+		src = src.."local _"..i.."="..lookup[i]..";";
 	end
-	f = f.."return "..name..";end";
-	local f,err = loadstring(f, chunkname);
+	src = src.."return "..name..";end";
+	local f,err = loadstring(src, chunkname);
 	if not f then error(err); end
 	return f(setmetatable, stanza_mt);
 end