-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·36 lines (30 loc) · 886 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var fs = require('fs');
var path = require('path');
var Handlebars = require('handlebars');
var helpers = require('handlebars-helpers')({
handlebars: Handlebars
});
function render(resume) {
var css = fs.readFileSync(__dirname + "/style.css", "utf-8");
var tpl = fs.readFileSync(__dirname + "/resume.hbs", "utf-8");
var partialsDir = path.join(__dirname, 'partials');
var filenames = fs.readdirSync(partialsDir);
filenames.forEach(function (filename) {
var matches = /^([^.]+).hbs$/.exec(filename);
if (!matches) {
return;
}
var name = matches[1];
var filepath = path.join(partialsDir, filename)
var template = fs.readFileSync(filepath, 'utf8');
Handlebars.registerPartial(name, template);
});
Handlebars.registerPartial('css', css);
return Handlebars.compile(tpl)({
// css: css,
resume: resume
});
}
module.exports = {
render: render
};