diff --git a/dist/helpers/generic-helpers.js b/dist/helpers/generic-helpers.js index 5fd4944..d9804ee 100644 --- a/dist/helpers/generic-helpers.js +++ b/dist/helpers/generic-helpers.js @@ -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); + } } }; diff --git a/src/helpers/generic-helpers.coffee b/src/helpers/generic-helpers.coffee index 79724fe..a8116f9 100644 --- a/src/helpers/generic-helpers.coffee +++ b/src/helpers/generic-helpers.coffee @@ -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.