satelito

Static [web] site (or page) generator (ssg) made with Lua script.
git clone git://soucy.cc/satelito.git
Log | Files | Refs | README

commit a3d14bb950593e642810d0509f58ea477a0786a7
parent 7edd3cbf1797aaff4313209c59e4a1ba2dd21e9d
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Wed,  9 Feb 2022 08:27:53 -0500

Add an include function to inject partial templates

Diffstat:
Msatelito/model.lua | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/satelito/model.lua b/satelito/model.lua @@ -73,7 +73,14 @@ function model.set(filepath, config, contentdir) pagemeta.navigation = pagemeta.navigation or 'navigation' pagemeta.footer = pagemeta.footer or 'footer' pagemeta.feed = pagemeta.feed or 'feed.xml' - pagemeta.partial = pagemeta.partial or nil + + pagemeta.include = function(templatename) + -- Include a partial template and compile it + -- @usage <%- include("test-partial") %> + local inc = etlua.compile(file.read(template.find(templates, templatename))) + + return inc(pagemeta) + end -- Include a partial template and compile it -- @usage <%- include("test-partial") %>