Commit 08a46906 authored by wu-lee's avatar wu-lee

serve.js - load lib/helpers.js into handlebars used for email

parent 14b3e308
......@@ -36,7 +36,7 @@ module.exports = {
/** Html escapes text, but converts adjacent newlines into paragraph tags */
parags: function() {
const [opts, text] = getopts(arguments);
var [opts, text] = getopts(arguments);
text = Handlebars.Utils.escapeExpression(text);
text = text.replace(/\n\s*\n/mg, '<p>');
return new Handlebars.SafeString(text);
......
......@@ -2,6 +2,7 @@
const express = require('express');
const fs = require('fs');
const handlebars = require('handlebars');
const handlebarsHelpers = require('./lib/helpers.js');
const metalsmith = require('./metalsmith.js');
const email = require('./lib/email.js');
const git = require('./lib/git.js')({});
......@@ -47,6 +48,9 @@ var fileOptions = {
// one required field in submitted data is an 'email' field with a
// recipient address. All fields, plus parts of the config, are
// supplied to the templates.
for(var name in handlebarsHelpers) {
handlebars.registerHelper(name, handlebarsHelpers[name]);
}
function defineTemplateLoader(file, name, defaultTemplate) {
if (!file) {
maillog.warn(`no configured ${name} template file, using default`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment