SSOwat/lustache.lua
2018-06-07 11:56:34 +02:00

29 lines
754 B
Lua

-- lustache: Lua mustache template parsing.
-- Copyright 2013 Olivine Labs, LLC <projects@olivinelabs.com>
-- MIT Licensed.
module('lustache', package.seeall)
local string_gmatch = string.gmatch
function string.split(str, sep)
local out = {}
for m in string_gmatch(str, "[^"..sep.."]+") do out[#out+1] = m end
return out
end
local lustache = {
name = "lustache",
version = "1.3.1-0",
renderer = require("lustache.renderer"):new(),
}
return setmetatable(lustache, {
__index = function(self, idx)
if self.renderer[idx] then return self.renderer[idx] end
end,
__newindex = function(self, idx, val)
if idx == "partials" then self.renderer.partials = val end
if idx == "tags" then self.renderer.tags = val end
end
})