ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit 82257f9dbd38e3f67ef15168c2cc61330e1eedf0
parent e5d4e5457e88244eed46a1aaf656449d97b05758
Author: Hugo Soucy <hsoucy@kronostechnologies.com>
Date:   Tue, 23 Oct 2018 09:33:35 -0400

Add a function to render etlua

Diffstat:
Mferron/utilities/template-utils.lua | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/ferron/utilities/template-utils.lua b/ferron/utilities/template-utils.lua @@ -1,5 +1,6 @@ -- local lustache = require "lustache" +local etlua = require "etlua" local path = require "path" local fileutils = require "ferron.utilities.file-utils" @@ -21,7 +22,8 @@ function templateutils.selecttemplate(index, templatename) end -- etlua or mustache -- etlua templates will outrank the mustache ones - return assert(path.isfile(template .. ".etlua") and template .. ".etlua" or template .. ".mustache", "You need to add some templates to your site.") + return assert(path.isfile(template .. ".etlua") and template .. ".etlua" or template .. ".mustache", + "You need to add some templates to your site.") end -- process mustache @@ -37,6 +39,12 @@ function templateutils.processmustache(tpl, partialspath, data) return lustache:render(tpl, data, partials) end +function templateutils.processetlua(template, data) + local tpl = etlua.compile(template) + + return tpl(data) +end + -- process template function templateutils.processtemplate(template, data) print(template, data)