motyl

Opinionated blog-aware static site generator written in Ruby
Log | Files | Refs | README | LICENSE

commit 7d45a5b2b2d6edf2bae47aa042d6acaf0b7ea642
parent 93af4f51a6549130f3037b87ee9c6dc17d819ba7
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri,  4 Mar 2016 22:42:34 +0100

Adding a renderTemplate function instead of calling lustache:render directly

Diffstat:
Mmotyl.lua | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/motyl.lua b/motyl.lua @@ -7,7 +7,7 @@ # http://www.cambus.net/motyl/ # # # # Created: 2016-02-16 # -# Last Updated: 2016-03-03 # +# Last Updated: 2016-03-04 # # # # Motyl is released under the BSD 3-Clause license. # # See LICENSE file for details. # @@ -44,6 +44,10 @@ local function loadMD(path) return markdown(readFile(path)) end +local function renderTemplate(template, data, templates) + return lustache:render(template, data, templates) +end + local function sortDates(a,b) return a.date > b.date end @@ -99,7 +103,7 @@ local function render(directory) end end - output = lustache:render(templates[directory], data, templates) + output = renderTemplate(templates[directory], data, templates) lfs.mkdir(data.site.destination .. path) writeFile(data.site.destination .. path .. "/index.html", output) @@ -123,7 +127,7 @@ data.page.title = data.site.title data.page.description = data.site.description data.page.keywords = data.site.keywords -output = lustache:render(templates.archives, data, templates) +output = renderTemplate(templates.archives, data, templates) writeFile(data.site.destination .. "index.html", output) status("Rendering index.html") data.page = {} @@ -139,7 +143,7 @@ for category in pairs(data.site.categories) do data.page.title = category data.page.url = categoryURL data.site.posts = data.site.categories[category] - output = lustache:render(templates.archives, data, templates) + output = renderTemplate(templates.archives, data, templates) lfs.mkdir(data.site.destination .. "categories/" .. categoryURL) writeFile(data.site.destination .. "categories/" .. categoryURL .. "index.html", output)