ferron

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

feed.lua (827B)


      1 -- feed.lua
      2 local feed = {}
      3 local feedmeta = {
      4   __call = function(self, key, vars)
      5     print(key)
      6   end
      7 }
      8 
      9 local site = require 'ferron.site'
     10 local fl = require 'ferron.utilities.file-utils'
     11 local tp = require 'ferron.utilities.template-utils'
     12 
     13 function feed.makefeed(data, destination)
     14   local feedtypes = site.config.feedtypes
     15   local feeddata = data
     16 
     17   for k, v in pairs(feedtypes) do
     18     local feedtemplate = site.templates .. '/feed/' .. k .. '.mustache'
     19 
     20     if fl.isFile(feedtemplate) then
     21       fl.pushfilecontent(
     22         destination .. '/' .. v.name .. v.extension,
     23         tp.rendermustache(
     24           fl.pullfilecontent(feedtemplate),
     25           feeddata
     26         )
     27       )
     28     else
     29       print('*** Warning! The `' .. feedtemplate .. '` template is missing!')
     30     end
     31   end
     32 end
     33 
     34 return setmetatable(feed, feedmeta)