comparison mod_register_web/mod_register_web.lua @ 1572:1aa894db3585

mod_register_web: Add option for specifying path to templates
author Kim Alvefur <zash@zash.se>
date Wed, 19 Nov 2014 10:19:51 +0100
parents 5e1f7af23cf0
children c56baec031e8
comparison
equal deleted inserted replaced
1571:eed7db9f3157 1572:1aa894db3585
10 nick = true; name = true; first = true; last = true; email = true; 10 nick = true; name = true; first = true; last = true; email = true;
11 address = true; city = true; state = true; zip = true; 11 address = true; city = true; state = true; zip = true;
12 phone = true; url = true; date = true; 12 phone = true; url = true; date = true;
13 } 13 }
14 14
15 local template_path = module:get_option_string("register_web_template", "templates");
15 function template(data) 16 function template(data)
16 -- Like util.template, but deals with plain text 17 -- Like util.template, but deals with plain text
17 return { apply = function(values) return (data:gsub("{([^}]+)}", values)); end } 18 return { apply = function(values) return (data:gsub("{([^}]+)}", values)); end }
18 end 19 end
19 20
20 local function get_template(name) 21 local function get_template(name)
21 local fh = assert(module:load_resource("templates"..path_sep..name..".html")); 22 local fh = assert(module:load_resource(template_path..path_sep..name..".html"));
22 local data = assert(fh:read("*a")); 23 local data = assert(fh:read("*a"));
23 fh:close(); 24 fh:close();
24 return template(data); 25 return template(data);
25 end 26 end
26 27