forked from jsonresume/jsonresume-theme-modern
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
56 lines (50 loc) · 1.46 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var fs = require('fs');
var gravatar = require('gravatar');
var _ = require('lodash')
var Mustache = require('mustache');
function render(resumeObject) {
_.each(resumeObject.work, function(w){
w.startDateYear = w.startDate.substr(0,4);
if(w.endDate) {
w.endDateYear = w.endDate.substr(0,4);
} else {
w.endDateYear = 'Present'
}
});
_.each(resumeObject.volunteer, function(v){
v.startDateYear = v.startDate.substr(0,4);
if(v.endDate) {
v.endDateYear = v.endDate.substr(0,4);
} else {
v.endDateYear = 'Present'
}
});
_.each(resumeObject.education, function(e){
if( !e.area || !e.studyType ){
e.educationDetail = (e.area == null ? '' : e.area) + (e.studyType == null ? '' : e.studyType);
} else {
e.educationDetail = e.area + ", "+ e.studyType;
}
e.startDateYear = e.startDate.substr(0,4);
if(e.endDate) {
e.endDateYear = e.endDate.substr(0,4);
} else {
e.endDateYear = 'Present'
}
});
if(resumeObject.basics && resumeObject.basics.email) {
resumeObject.basics.gravatar = gravatar.url(resumeObject.basics.email, {
s: '100',
r: 'pg',
d: 'mm'
});
}
var theme = fs.readFileSync(__dirname + '/resume.template', 'utf8');
var css = fs.readFileSync(__dirname + "/resume.css", "utf-8");
resumeObject.css = css;
var resumeHTML = Mustache.render(theme, resumeObject);
return resumeHTML;
};
module.exports = {
render: render
}