1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-09 23:37:09 +01: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
4 changed files with 44 additions and 9 deletions

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()