1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-24 01:10:11 +00:00

feat: introduce two skill-related helpers

This commit is contained in:
hacksalot 2018-02-07 05:55:27 -05:00
parent 38a073b09a
commit c08c5f0fa3
No known key found for this signature in database
GPG Key ID: 2F343EC247CA4B06
4 changed files with 44 additions and 9 deletions

View File

@ -43,6 +43,16 @@ Block helper definitions for HackMyResume / FluentCV.
}
return ret;
},
ifHasSkill: function(rez, skill, options) {
var ret, skUp;
skUp = skill.toUpperCase();
ret = _.some(rez.skills.list, function(sk) {
return (skUp.toUpperCase() === sk.name.toUpperCase()) && sk.years;
}, this);
if (ret) {
return options.fn(this);
}
},
/**
Emit the enclosed content if the resume has the named

View File

@ -6,7 +6,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
*/
(function() {
var FS, FluentDate, GenericHelpers, H2W, HMSTATUS, LO, MD, PATH, XML, _, _fromTo, _reportError, moment, printf, skillLevelToIndex, unused;
var FS, FluentDate, GenericHelpers, H2W, HMSTATUS, LO, MD, PATH, XML, _, _fromTo, _reportError, _skillLevelToIndex, moment, printf, unused;
MD = require('marked');
@ -391,7 +391,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
*/
skillColor: function(lvl) {
var idx, skillColors;
idx = skillLevelToIndex(lvl);
idx = _skillLevelToIndex(lvl);
skillColors = (this.theme && this.theme.palette && this.theme.palette.skillLevels) || ['#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000'];
return skillColors[idx];
},
@ -402,7 +402,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
*/
skillHeight: function(lvl) {
var idx;
idx = skillLevelToIndex(lvl);
idx = _skillLevelToIndex(lvl);
return ['38.25', '30', '16', '8', '0'][idx];
},
@ -541,6 +541,17 @@ Generic template helper definitions for HackMyResume / FluentCV.
ret = PAD(stringOrArray, stringOrArray.length + Math.abs(padAmount), null, padAmount < 0 ? PAD.LEFT : PAD.RIGHT);
}
return ret;
},
skillYears: function(skill, rez) {
var sk;
sk = _.find(rez.skills.list, function(sk) {
return sk.name.toUpperCase() === skill.toUpperCase();
});
if (sk) {
return sk.years;
} else {
return '?';
}
}
};
@ -599,7 +610,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
return '';
};
skillLevelToIndex = function(lvl) {
_skillLevelToIndex = function(lvl) {
var idx, intVal;
idx = 0;
if (String.is(lvl)) {

View File

@ -38,6 +38,14 @@ BlockHelpers = module.exports =
ifHasSkill: ( rez, skill, options ) ->
skUp = skill.toUpperCase()
ret = _.some rez.skills.list, (sk) ->
(skUp.toUpperCase() == sk.name.toUpperCase()) and sk.years
, @
options.fn @ if ret
###*
Emit the enclosed content if the resume has the named
property or subproperty.
@ -55,4 +63,4 @@ BlockHelpers = module.exports =
Return true if either value is truthy.
@method either
###
either: ( lhs, rhs, options ) -> options.fn @ if lhs || rhs
either: ( lhs, rhs, options ) -> options.fn @ if lhs || rhs

View File

@ -329,6 +329,7 @@ GenericHelpers = module.exports =
# If not provided by the user, stitle should default to sname. ps.
# Handlebars silently passes in the options object to the last param,
# where in Underscore stitle will be null/undefined, so we check both.
# TODO: not actually sure that's true, given that we _.wrap these functions
stitle = (stitle && String.is(stitle) && stitle) || sname
# If there's a section title override, use it.
@ -342,7 +343,7 @@ GenericHelpers = module.exports =
wpml: ( txt, inline ) ->
return '' if !txt
inline = (inline && !inline.hash) || false
txt = XML(txt.trim())
txt = XML txt.trim()
txt = if inline then MD(txt).replace(/^\s*<p>|<\/p>\s*$/gi, '') else MD(txt)
txt = H2W( txt )
return txt
@ -376,7 +377,7 @@ GenericHelpers = module.exports =
'#FFFFAA').
###
skillColor: ( lvl ) ->
idx = skillLevelToIndex lvl
idx = _skillLevelToIndex lvl
skillColors = (this.theme && this.theme.palette &&
this.theme.palette.skillLevels) ||
[ '#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000' ]
@ -389,7 +390,7 @@ GenericHelpers = module.exports =
@method lastWord
###
skillHeight: ( lvl ) ->
idx = skillLevelToIndex lvl
idx = _skillLevelToIndex lvl
['38.25', '30', '16', '8', '0'][idx]
@ -505,6 +506,11 @@ GenericHelpers = module.exports =
ret
skillYears: ( skill, rez ) ->
sk = _.find rez.skills.list, (sk) -> sk.name.toUpperCase() == skill.toUpperCase()
if sk then sk.years else '?'
###*
Report an error to the outside world without throwing an exception. Currently
@ -562,7 +568,7 @@ _fromTo = ( dateA, dateB, fmt, sep, fallback ) ->
skillLevelToIndex = ( lvl ) ->
_skillLevelToIndex = ( lvl ) ->
idx = 0
if String.is( lvl )
lvl = lvl.trim().toLowerCase()