mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-24 01:10:11 +00:00
feat: introduce stringOrObject & linkMD helpers
This commit is contained in:
parent
c08c5f0fa3
commit
8648befcdd
33
dist/helpers/generic-helpers.js
vendored
33
dist/helpers/generic-helpers.js
vendored
@ -369,6 +369,18 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Emit a conditional Markdown link.
|
||||
@method link
|
||||
*/
|
||||
linkMD: function(text, url) {
|
||||
if (url && url.trim()) {
|
||||
return '[' + text + '](' + url + ')';
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Return the last word of the specified text.
|
||||
@method lastWord
|
||||
@ -527,6 +539,10 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return options.inverse(this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Emit padded text.
|
||||
*/
|
||||
pad: function(stringOrArray, padAmount, unused) {
|
||||
var PAD, ret;
|
||||
stringOrArray = stringOrArray || '';
|
||||
@ -542,6 +558,11 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
Given the name of a skill ("JavaScript" or "HVAC repair"), return the number
|
||||
of years assigned to that skill in the resume.skills.list collection.
|
||||
*/
|
||||
skillYears: function(skill, rez) {
|
||||
var sk;
|
||||
sk = _.find(rez.skills.list, function(sk) {
|
||||
@ -552,6 +573,18 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
} else {
|
||||
return '?';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Given an object that may be a string or an object, return it as-is if it's a
|
||||
string, otherwise return the value at obj[objPath].
|
||||
*/
|
||||
stringOrObject: function(obj, objPath, rez) {
|
||||
if (_.isString(obj)) {
|
||||
return obj;
|
||||
} else {
|
||||
return LO.get(obj, objPath);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -359,6 +359,15 @@ GenericHelpers = module.exports =
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Emit a conditional Markdown link.
|
||||
@method link
|
||||
###
|
||||
linkMD: ( text, url ) ->
|
||||
return if url && url.trim() then ('[' + text + '](' + url + ')') else text
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Return the last word of the specified text.
|
||||
@method lastWord
|
||||
@ -492,6 +501,9 @@ GenericHelpers = module.exports =
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Emit padded text.
|
||||
###
|
||||
pad: (stringOrArray, padAmount, unused ) ->
|
||||
stringOrArray = stringOrArray || ''
|
||||
padAmount = padAmount || 0
|
||||
@ -506,12 +518,26 @@ GenericHelpers = module.exports =
|
||||
ret
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Given the name of a skill ("JavaScript" or "HVAC repair"), return the number
|
||||
of years assigned to that skill in the resume.skills.list collection.
|
||||
###
|
||||
skillYears: ( skill, rez ) ->
|
||||
sk = _.find rez.skills.list, (sk) -> sk.name.toUpperCase() == skill.toUpperCase()
|
||||
if sk then sk.years else '?'
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Given an object that may be a string or an object, return it as-is if it's a
|
||||
string, otherwise return the value at obj[objPath].
|
||||
###
|
||||
stringOrObject: ( obj, objPath, rez ) ->
|
||||
if _.isString obj then obj else LO.get obj, objPath
|
||||
|
||||
|
||||
|
||||
###*
|
||||
Report an error to the outside world without throwing an exception. Currently
|
||||
relies on kludging the running verb into. opts.
|
||||
|
Loading…
Reference in New Issue
Block a user