forked from umrysh/jsonresume-theme-elegant
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
66 lines (59 loc) · 1.91 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
57
58
59
60
61
62
63
64
65
66
var fs = require('fs');
var gravatar = require('gravatar');
var Mustache = require('mustache');
var _ = require('underscore');
function hasPersonalEmail(resumeObject) {
return (resumeObject.bio && resumeObject.bio.email && resumeObject.bio.email.personal);
}
function render (resumeObject) {
if (hasPersonalEmail(resumeObject)) {
resumeObject.bio.gravatar = gravatar.url(resumeObject.bio.email.personal, {
s: '100',
r: 'pg',
d: 'mm'
});
}
_.each(resumeObject.work, function (work_experience) {
work_experience.startDate = work_experience.startDate;
if (work_experience.endDate && work_experience.startDate){
if(work_experience.endDate==work_experience.startDate)
{
work_experience.endDate = "";
}else{
work_experience.endDate = work_experience.endDate;
}
}else{
work_experience.endDate = 'Present';
}
});
_.each(resumeObject.education, function(education_experience){
education_experience.startDate = education_experience.startDate;
if (education_experience.endDate && education_experience.startDate){
if(education_experience.endDate==education_experience.startDate)
{
education_experience.endDate = "";
}else{
education_experience.endDate = education_experience.endDate;
}
}else{
education_experience.endDate = 'Present';
}
});
_.each(resumeObject.volunteer, function(volunteer_experience){
volunteer_experience.startDate = volunteer_experience.startDate;
if (volunteer_experience.endDate && volunteer_experience.startDate){
if(volunteer_experience.endDate==volunteer_experience.startDate)
{
volunteer_experience.endDate = "";
}else{
volunteer_experience.endDate = volunteer_experience.endDate;
}
}else{
volunteer_experience.endDate = 'Present';
}
});
var theme = fs.readFileSync(__dirname + '/resume.template', 'utf8');
var resumeHTML = Mustache.render(theme, resumeObject);
return resumeHTML;
}
module.exports = { render: render };