end
end
-function nb:_ngx_location_md()
- return
+function nb:ngx_tmpl(content,fheader,ffooter)
+ ngx.ctx.tmpl_content = content
+ self:ngx_location_tmpl(fheader,ffooter)
end
-function nb:ngx_location_md(fheader,ffooter)
+function nb:ngx_location_tmpl(fheader,ffooter)
-- See https://github.com/bungle/lua-resty-template
-- location ~ \.(md|html)$ {
--- content_by_lua 'package.path = ngx.var.NB_ROOT .. "/lib/lua/?.lua;" .. package.path local nb = require("nb") nb:ngx_location_md()';
+-- content_by_lua 'package.path = ngx.var.NB_ROOT .. "/lib/lua/?.lua;" .. package.path local nb = require("nb") nb:ngx_location_tmpl()';
-- }
if not fheader then fheader = ngx.var.document_root .. "/header.html" end
if not ffooter then ffooter = ngx.var.document_root .. "/footer.html" end
local file = ngx.var.document_root .. ngx.var.uri;
local content = self:readall(file)
+ if ngx.ctx.tmpl_content then content = ngx.ctx.tmpl_content end
if not content then return end
local vars = {}
elseif string.match(file,'%.html?$') then
- else
+ elseif not ngx.ctx.tmpl_content then
ishtml = false
end