json-theme-even-fork/index.js

33 lines
806 B
JavaScript
Raw Normal View History

2018-09-23 20:28:05 +02:00
var fs = require("fs");
var Handlebars = require("handlebars");
module.exports = {
render: render
};
function render(resume) {
var css = fs.readFileSync(__dirname + "/style.css", "utf-8");
2020-02-10 20:39:42 +01:00
var template = fs.readFileSync(__dirname + "/resume.hbs", "utf-8");
2018-09-23 20:28:05 +02:00
return Handlebars.compile(template)({
css: css,
resume: resume
});
}
Handlebars.registerHelper("formatDate", function(dateString) {
const date = new Date(dateString);
return date.toLocaleDateString("en", {
month: "short",
year: "numeric"
});
});
Handlebars.registerHelper("join", function(arr, separator) {
separator = typeof separator === "string" ? separator : ", ";
return arr.join(separator);
});
Handlebars.registerHelper("nl2br", function(value) {
return (value || "").replace(/\n/g, "</p><p>");
});