mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-10 07:47:07 +01:00
chore: update project dependencies
This commit is contained in:
25
dist/helpers/block-helpers.js
vendored
25
dist/helpers/block-helpers.js
vendored
@ -1,11 +1,10 @@
|
||||
|
||||
/**
|
||||
Block helper definitions for HackMyResume / FluentCV.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module helpers/generic-helpers
|
||||
*/
|
||||
|
||||
(function() {
|
||||
/**
|
||||
Block helper definitions for HackMyResume / FluentCV.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module helpers/generic-helpers
|
||||
*/
|
||||
/** Block helper function definitions. */
|
||||
var BlockHelpers, HMSTATUS, LO, _, unused;
|
||||
|
||||
HMSTATUS = require('../core/status-codes');
|
||||
@ -16,15 +15,11 @@ Block helper definitions for HackMyResume / FluentCV.
|
||||
|
||||
unused = require('../utils/string');
|
||||
|
||||
|
||||
/** Block helper function definitions. */
|
||||
|
||||
BlockHelpers = module.exports = {
|
||||
|
||||
/**
|
||||
Emit the enclosed content if the resume has a section with
|
||||
the specified name. Otherwise, emit an empty string ''.
|
||||
*/
|
||||
*/
|
||||
section: function(title, options) {
|
||||
var obj, ret;
|
||||
title = title.trim().toLowerCase();
|
||||
@ -53,22 +48,20 @@ Block helper definitions for HackMyResume / FluentCV.
|
||||
return options.fn(this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Emit the enclosed content if the resume has the named
|
||||
property or subproperty.
|
||||
*/
|
||||
*/
|
||||
has: function(title, options) {
|
||||
title = title && title.trim().toLowerCase();
|
||||
if (LO.get(this.r, title)) {
|
||||
return options.fn(this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Return true if either value is truthy.
|
||||
@method either
|
||||
*/
|
||||
*/
|
||||
either: function(lhs, rhs, options) {
|
||||
if (lhs || rhs) {
|
||||
return options.fn(this);
|
||||
|
14
dist/helpers/console-helpers.js
vendored
14
dist/helpers/console-helpers.js
vendored
@ -1,11 +1,9 @@
|
||||
|
||||
/**
|
||||
Generic template helper definitions for command-line output.
|
||||
@module console-helpers.js
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
/**
|
||||
Generic template helper definitions for command-line output.
|
||||
@module console-helpers.js
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var CHALK, LO, PAD, _, consoleFormatHelpers;
|
||||
|
||||
PAD = require('string-padding');
|
||||
@ -21,7 +19,7 @@ Generic template helper definitions for command-line output.
|
||||
consoleFormatHelpers = module.exports = {
|
||||
v: function(val, defaultVal, padding, style) {
|
||||
var retVal, spaces;
|
||||
retVal = val === null || val === void 0 ? defaultVal : val;
|
||||
retVal = (val === null || val === void 0) ? defaultVal : val;
|
||||
spaces = 0;
|
||||
if (String.is(padding)) {
|
||||
spaces = parseInt(padding, 10);
|
||||
|
194
dist/helpers/generic-helpers.js
vendored
194
dist/helpers/generic-helpers.js
vendored
@ -1,11 +1,17 @@
|
||||
|
||||
/**
|
||||
Generic template helper definitions for HackMyResume / FluentCV.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module helpers/generic-helpers
|
||||
*/
|
||||
|
||||
(function() {
|
||||
/**
|
||||
Generic template helper definitions for HackMyResume / FluentCV.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module helpers/generic-helpers
|
||||
*/
|
||||
/** Generic template helper function definitions. */
|
||||
/**
|
||||
Format a from/to date range for display.
|
||||
*/
|
||||
/**
|
||||
Report an error to the outside world without throwing an exception. Currently
|
||||
relies on kludging the running verb into. opts.
|
||||
*/
|
||||
var FS, FluentDate, GenericHelpers, H2W, HMSTATUS, LO, MD, PATH, XML, _, _fromTo, _reportError, _skillLevelToIndex, moment, printf, unused;
|
||||
|
||||
MD = require('marked');
|
||||
@ -32,11 +38,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
|
||||
unused = require('../utils/string');
|
||||
|
||||
|
||||
/** Generic template helper function definitions. */
|
||||
|
||||
GenericHelpers = module.exports = {
|
||||
|
||||
/**
|
||||
Emit a formatted string representing the specified datetime.
|
||||
Convert the input date to the specified format through Moment.js. If date is
|
||||
@ -49,7 +51,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
Moment.js-compatible datetime format.
|
||||
@param {string|Moment} fallback A fallback value to use if the specified date
|
||||
is null, undefined, or falsy.
|
||||
*/
|
||||
*/
|
||||
formatDate: function(datetime, dtFormat, fallback) {
|
||||
var momentDate;
|
||||
if (datetime == null) {
|
||||
@ -58,22 +60,32 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
if (dtFormat == null) {
|
||||
dtFormat = 'YYYY-MM';
|
||||
}
|
||||
// If a Moment.js object was passed in, just call format on it
|
||||
if (datetime && moment.isMoment(datetime)) {
|
||||
return datetime.format(dtFormat);
|
||||
}
|
||||
if (String.is(datetime)) {
|
||||
// If a string was passed in, convert to Moment using the 2-paramter
|
||||
// constructor with an explicit format string.
|
||||
momentDate = moment(datetime, dtFormat);
|
||||
if (momentDate.isValid()) {
|
||||
return momentDate.format(dtFormat);
|
||||
}
|
||||
// If that didn't work, try again with the single-parameter constructor
|
||||
// but this may throw a deprecation warning
|
||||
momentDate = moment(datetime);
|
||||
if (momentDate.isValid()) {
|
||||
return momentDate.format(dtFormat);
|
||||
}
|
||||
}
|
||||
// We weren't able to format the provided datetime. Now do one of three
|
||||
// things.
|
||||
// 1. If datetime is non-null/non-falsy, return it. For this helper,
|
||||
// string date values that we can't parse are assumed to be display dates.
|
||||
// 2. If datetime IS null or falsy, use the value from the fallback.
|
||||
// 3. If the fallback value is specifically 'true', emit 'Present'.
|
||||
return datetime || (typeof fallback === 'string' ? fallback : (fallback === true ? 'Present' : ''));
|
||||
},
|
||||
|
||||
/**
|
||||
Emit a formatted string representing the specified datetime.
|
||||
@param {string} dateValue A raw date value from the FRESH or JRS resume.
|
||||
@ -81,7 +93,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
compatible with Moment.js datetime formats.
|
||||
@param {string} [dateDefault=null] The default date value to use if the dateValue
|
||||
parameter is null, undefined, or falsy.
|
||||
*/
|
||||
*/
|
||||
date: function(dateValue, dateFormat, dateDefault) {
|
||||
var dateValueMoment, dateValueSafe, reserved;
|
||||
if (!dateDefault || !String.is(dateDefault)) {
|
||||
@ -107,30 +119,27 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
}
|
||||
return dateValue;
|
||||
},
|
||||
|
||||
/**
|
||||
Given a resume sub-object with a start/end date, format a representation of
|
||||
the date range.
|
||||
*/
|
||||
*/
|
||||
dateRange: function(obj, fmt, sep, fallback) {
|
||||
if (!obj) {
|
||||
return '';
|
||||
}
|
||||
return _fromTo(obj.start, obj.end, fmt, sep, fallback);
|
||||
},
|
||||
|
||||
/**
|
||||
Format a from/to date range for display.
|
||||
@method toFrom
|
||||
*/
|
||||
*/
|
||||
fromTo: function() {
|
||||
return _fromTo.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
Return a named color value as an RRGGBB string.
|
||||
@method toFrom
|
||||
*/
|
||||
*/
|
||||
color: function(colorName, colorDefault) {
|
||||
var ret;
|
||||
if (!(colorName && colorName.trim())) {
|
||||
@ -150,12 +159,11 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return ret;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Emit the size of the specified named font.
|
||||
@param key {String} A named style from the "fonts" section of the theme's
|
||||
theme.json file. For example: 'default' or 'heading1'.
|
||||
*/
|
||||
*/
|
||||
fontSize: function(key, defSize, units) {
|
||||
var fontSpec, hasDef, ret;
|
||||
ret = '';
|
||||
@ -170,18 +178,22 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
} else if (GenericHelpers.theme.fonts) {
|
||||
fontSpec = LO.get(GenericHelpers.theme.fonts, this.format + '.' + key);
|
||||
if (!fontSpec) {
|
||||
// Check for an "all" format
|
||||
if (GenericHelpers.theme.fonts.all) {
|
||||
fontSpec = GenericHelpers.theme.fonts.all[key];
|
||||
}
|
||||
}
|
||||
if (fontSpec) {
|
||||
// fontSpec can be a string, an array, or an object
|
||||
if (String.is(fontSpec)) {
|
||||
|
||||
// No font size was specified, only a font family.
|
||||
} else if (_.isArray(fontSpec)) {
|
||||
if (!String.is(fontSpec[0])) {
|
||||
ret = fontSpec[0].size;
|
||||
}
|
||||
} else {
|
||||
// A font description object.
|
||||
ret = fontSpec.size;
|
||||
}
|
||||
}
|
||||
@ -200,7 +212,6 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
Emit the font face (such as 'Helvetica' or 'Calibri') associated with the
|
||||
provided key.
|
||||
@ -208,7 +219,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
theme.json file. For example: 'default' or 'heading1'.
|
||||
@param defFont {String} The font to use if the specified key isn't present.
|
||||
Can be any valid font-face name such as 'Helvetica Neue' or 'Calibri'.
|
||||
*/
|
||||
*/
|
||||
fontFace: function(key, defFont) {
|
||||
var fontSpec, hasDef, ret;
|
||||
ret = '';
|
||||
@ -220,19 +231,25 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
expected: 'key'
|
||||
});
|
||||
return ret;
|
||||
// If the theme has a "fonts" section, lookup the font face.
|
||||
} else if (GenericHelpers.theme.fonts) {
|
||||
fontSpec = LO.get(GenericHelpers.theme.fonts, this.format + '.' + key);
|
||||
if (!fontSpec) {
|
||||
// Check for an "all" format
|
||||
if (GenericHelpers.theme.fonts.all) {
|
||||
fontSpec = GenericHelpers.theme.fonts.all[key];
|
||||
}
|
||||
}
|
||||
if (fontSpec) {
|
||||
// fontSpec can be a string, an array, or an object
|
||||
if (String.is(fontSpec)) {
|
||||
ret = fontSpec;
|
||||
} else if (_.isArray(fontSpec)) {
|
||||
// An array of fonts were specified. Each one could be a string
|
||||
// or an object
|
||||
ret = String.is(fontSpec[0]) ? fontSpec[0] : fontSpec[0].name;
|
||||
} else {
|
||||
// A font description object.
|
||||
ret = fontSpec.name;
|
||||
}
|
||||
}
|
||||
@ -250,18 +267,6 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
Emit a comma-delimited list of font names suitable associated with the
|
||||
provided key.
|
||||
@param key {String} A named style from the "fonts" section of the theme's
|
||||
theme.json file. For example: 'default' or 'heading1'.
|
||||
@param defFontList {Array} The font list to use if the specified key isn't
|
||||
present. Can be an array of valid font-face name such as 'Helvetica Neue'
|
||||
or 'Calibri'.
|
||||
@param sep {String} The default separator to use in the rendered output.
|
||||
Defaults to ", " (comma with a space).
|
||||
*/
|
||||
fontList: function(key, defFontList, sep) {
|
||||
var fontSpec, hasDef, ret;
|
||||
ret = '';
|
||||
@ -280,14 +285,18 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
}
|
||||
}
|
||||
if (fontSpec) {
|
||||
// fontSpec can be a string, an array, or an object
|
||||
if (String.is(fontSpec)) {
|
||||
ret = fontSpec;
|
||||
} else if (_.isArray(fontSpec)) {
|
||||
// An array of fonts were specified. Each one could be a string
|
||||
// or an object
|
||||
fontSpec = fontSpec.map(function(ff) {
|
||||
return "'" + (String.is(ff) ? ff : ff.name) + "'";
|
||||
});
|
||||
ret = fontSpec.join(sep === void 0 ? ', ' : sep || '');
|
||||
} else {
|
||||
// A font description object.
|
||||
ret = fontSpec.name;
|
||||
}
|
||||
}
|
||||
@ -306,11 +315,6 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
Capitalize the first letter of the word. TODO: Rename
|
||||
@method section
|
||||
*/
|
||||
camelCase: function(val) {
|
||||
val = (val && val.trim()) || '';
|
||||
if (val) {
|
||||
@ -319,33 +323,35 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return val;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Display a user-overridable section title for a FRESH resume theme. Use this in
|
||||
lieue of hard-coding section titles.
|
||||
|
||||
|
||||
Usage:
|
||||
|
||||
{{sectionTitle "sectionName"}}
|
||||
{{sectionTitle "sectionName" "sectionTitle"}}
|
||||
|
||||
|
||||
{{sectionTitle "sectionName"}}
|
||||
{{sectionTitle "sectionName" "sectionTitle"}}
|
||||
|
||||
Example:
|
||||
|
||||
{{sectionTitle "Education"}}
|
||||
{{sectionTitle "Employment" "Project History"}}
|
||||
|
||||
|
||||
{{sectionTitle "Education"}}
|
||||
{{sectionTitle "Employment" "Project History"}}
|
||||
|
||||
@param sect_name The name of the section being title. Must be one of the
|
||||
top-level FRESH resume sections ("info", "education", "employment", etc.).
|
||||
@param sect_title The theme-specified section title. May be replaced by the
|
||||
user.
|
||||
@method sectionTitle
|
||||
*/
|
||||
*/
|
||||
sectionTitle: function(sname, stitle) {
|
||||
// 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.
|
||||
return (this.opts.stitles && this.opts.stitles[sname.toLowerCase().trim()]) || stitle;
|
||||
},
|
||||
|
||||
/** Convert inline Markdown to inline WordProcessingML. */
|
||||
wpml: function(txt, inline) {
|
||||
if (!txt) {
|
||||
return '';
|
||||
@ -356,11 +362,10 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
txt = H2W(txt);
|
||||
return txt;
|
||||
},
|
||||
|
||||
/**
|
||||
Emit a conditional link.
|
||||
@method link
|
||||
*/
|
||||
*/
|
||||
link: function(text, url) {
|
||||
if (url && url.trim()) {
|
||||
return '<a href="' + url + '">' + text + '</a>';
|
||||
@ -368,11 +373,10 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return text;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Emit a conditional Markdown link.
|
||||
@method link
|
||||
*/
|
||||
*/
|
||||
linkMD: function(text, url) {
|
||||
if (url && url.trim()) {
|
||||
return '[' + text + '](' + url + ')';
|
||||
@ -380,11 +384,10 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return text;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Return the last word of the specified text.
|
||||
@method lastWord
|
||||
*/
|
||||
*/
|
||||
lastWord: function(txt) {
|
||||
if (txt && txt.trim()) {
|
||||
return _.last(txt.split(' '));
|
||||
@ -392,7 +395,6 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Convert a skill level to an RGB color triplet. TODO: refactor
|
||||
@method skillColor
|
||||
@ -400,28 +402,26 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
("beginner", "intermediate", etc.), as an integer (1,5,etc), as a string
|
||||
integer ("1", "5", etc.), or as an RRGGBB color triplet ('#C00000',
|
||||
'#FFFFAA').
|
||||
*/
|
||||
*/
|
||||
skillColor: function(lvl) {
|
||||
var idx, skillColors;
|
||||
idx = _skillLevelToIndex(lvl);
|
||||
skillColors = (this.theme && this.theme.palette && this.theme.palette.skillLevels) || ['#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000'];
|
||||
return skillColors[idx];
|
||||
},
|
||||
|
||||
/**
|
||||
Return an appropriate height. TODO: refactor
|
||||
@method lastWord
|
||||
*/
|
||||
*/
|
||||
skillHeight: function(lvl) {
|
||||
var idx;
|
||||
idx = _skillLevelToIndex(lvl);
|
||||
return ['38.25', '30', '16', '8', '0'][idx];
|
||||
},
|
||||
|
||||
/**
|
||||
Return all but the last word of the input text.
|
||||
@method initialWords
|
||||
*/
|
||||
*/
|
||||
initialWords: function(txt) {
|
||||
if (txt && txt.trim()) {
|
||||
return _.initial(txt.split(' ')).join(' ');
|
||||
@ -429,11 +429,10 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Trim the protocol (http or https) from a URL/
|
||||
@method trimURL
|
||||
*/
|
||||
*/
|
||||
trimURL: function(url) {
|
||||
if (url && url.trim()) {
|
||||
return url.trim().replace(/^https?:\/\//i, '');
|
||||
@ -441,11 +440,10 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Convert text to lowercase.
|
||||
@method toLower
|
||||
*/
|
||||
*/
|
||||
toLower: function(txt) {
|
||||
if (txt && txt.trim()) {
|
||||
return txt.toLowerCase();
|
||||
@ -453,11 +451,10 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Convert text to lowercase.
|
||||
@method toLower
|
||||
*/
|
||||
*/
|
||||
toUpper: function(txt) {
|
||||
if (txt && txt.trim()) {
|
||||
return txt.toUpperCase();
|
||||
@ -465,7 +462,6 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Conditional stylesheet link. Creates a link to the specified stylesheet with
|
||||
<link> or embeds the styles inline with <style></style>, depending on the
|
||||
@ -474,9 +470,10 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
@param linkage {String} The default link method. Can be either `embed` or
|
||||
`link`. If omitted, defaults to `embed`. Can be overridden by the `--css`
|
||||
command-line switch.
|
||||
*/
|
||||
*/
|
||||
styleSheet: function(url, linkage) {
|
||||
var rawCss, renderedCss, ret;
|
||||
// Establish the linkage style
|
||||
linkage = this.opts.css || linkage || 'embed';
|
||||
ret = '';
|
||||
if (linkage === 'link') {
|
||||
@ -486,17 +483,20 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
renderedCss = this.engine.generateSimple(this, rawCss);
|
||||
ret = printf('<style>%s</style>', renderedCss);
|
||||
}
|
||||
// If the currently-executing template is inherited, append styles
|
||||
if (this.opts.themeObj.inherits && this.opts.themeObj.inherits.html && this.format === 'html') {
|
||||
ret += linkage === 'link' ? '<link href="' + this.opts.themeObj.overrides.path + '" rel="stylesheet" type="text/css">' : '<style>' + this.opts.themeObj.overrides.data + '</style>';
|
||||
}
|
||||
// TODO: It would be nice to use Handlebar.SafeString here, but these
|
||||
// are supposed to be generic helpers. Provide an equivalent, or expose
|
||||
// it when Handlebars is the chosen engine, which is most of the time.
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
Perform a generic comparison.
|
||||
See: http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates
|
||||
@method compare
|
||||
*/
|
||||
*/
|
||||
compare: function(lvalue, rvalue, options) {
|
||||
var operator, operators, result;
|
||||
if (arguments.length < 3) {
|
||||
@ -539,10 +539,9 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return options.inverse(this);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Emit padded text.
|
||||
*/
|
||||
*/
|
||||
pad: function(stringOrArray, padAmount, unused) {
|
||||
var PAD, ret;
|
||||
stringOrArray = stringOrArray || '';
|
||||
@ -558,11 +557,10 @@ 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) {
|
||||
@ -574,11 +572,10 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
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;
|
||||
@ -588,23 +585,14 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Report an error to the outside world without throwing an exception. Currently
|
||||
relies on kludging the running verb into. opts.
|
||||
*/
|
||||
|
||||
_reportError = function(code, params) {
|
||||
return GenericHelpers.opts.errHandler.err(code, params);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Format a from/to date range for display.
|
||||
*/
|
||||
|
||||
_fromTo = function(dateA, dateB, fmt, sep, fallback) {
|
||||
var dateATrim, dateBTrim, dateFrom, dateTemp, dateTo, reserved;
|
||||
// Prevent accidental use of safe.start, safe.end, safe.date
|
||||
// The dateRange helper is for raw dates only
|
||||
if (moment.isMoment(dateA) || moment.isMoment(dateB)) {
|
||||
_reportError(HMSTATUS.invalidHelperUse, {
|
||||
helper: 'dateRange'
|
||||
@ -614,6 +602,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
dateFrom = null;
|
||||
dateTo = null;
|
||||
dateTemp = null;
|
||||
// Check for 'current', 'present', 'now', '', null, and undefined
|
||||
dateA = dateA || '';
|
||||
dateB = dateB || '';
|
||||
dateATrim = dateA.trim().toLowerCase();
|
||||
@ -674,6 +663,25 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return idx;
|
||||
};
|
||||
|
||||
// Note [1] --------------------------------------------------------------------
|
||||
// Make sure it's precisely a string or array since some template engines jam
|
||||
// their options/context object into the last parameter and we are allowing the
|
||||
// defFont parameter to be omitted in certain cases. This is a little kludgy,
|
||||
// but works fine for this case. If we start doing this regularly, we should
|
||||
// rebind these parameters.
|
||||
|
||||
// Note [2]: -------------------------------------------------------------------
|
||||
// If execution reaches here, some sort of cosmic ray or sunspot has landed on
|
||||
// HackMyResume, or a theme author is deliberately messing with us by doing
|
||||
// something like:
|
||||
|
||||
// "fonts": {
|
||||
// "default": "",
|
||||
// "heading1": null
|
||||
// }
|
||||
|
||||
// Rather than sort it out, we'll just fall back to defFont.
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=generic-helpers.js.map
|
||||
|
54
dist/helpers/handlebars-helpers.js
vendored
54
dist/helpers/handlebars-helpers.js
vendored
@ -1,11 +1,9 @@
|
||||
|
||||
/**
|
||||
Template helper definitions for Handlebars.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module handlebars-helpers.js
|
||||
*/
|
||||
|
||||
(function() {
|
||||
/**
|
||||
Template helper definitions for Handlebars.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module handlebars-helpers.js
|
||||
*/
|
||||
var HANDLEBARS, HMS, _, blockHelpers, helpers, path;
|
||||
|
||||
HANDLEBARS = require('handlebars');
|
||||
@ -20,32 +18,38 @@ Template helper definitions for Handlebars.
|
||||
|
||||
HMS = require('../core/status-codes');
|
||||
|
||||
|
||||
/**
|
||||
Register useful Handlebars helpers.
|
||||
@method registerHelpers
|
||||
*/
|
||||
|
||||
*/
|
||||
module.exports = function(theme, rez, opts) {
|
||||
var curGlob, ex, glob, slash, wrappedHelpers;
|
||||
helpers.theme = theme;
|
||||
helpers.opts = opts;
|
||||
helpers.type = 'handlebars';
|
||||
// Prepare generic helpers for use with Handlebars. We do this by wrapping them
|
||||
// in a Handlebars-aware wrapper which calls the helper internally.
|
||||
wrappedHelpers = _.mapObject(helpers, function(hVal, hKey) {
|
||||
if (_.isFunction(hVal)) {
|
||||
return _.wrap(hVal, function(func) {
|
||||
var args;
|
||||
args = Array.prototype.slice.call(arguments);
|
||||
args.shift();
|
||||
args[args.length - 1] = rez;
|
||||
return func.apply(this, args);
|
||||
args.shift(); // lose the 1st element (func) [^1]
|
||||
//args.pop() # lose the last element (HB options hash)
|
||||
args[args.length - 1] = rez; // replace w/ resume object
|
||||
return func.apply(this, args); // call the generic helper
|
||||
});
|
||||
}
|
||||
return hVal;
|
||||
}, this);
|
||||
HANDLEBARS.registerHelper(wrappedHelpers);
|
||||
// Prepare Handlebars-specific helpers - "blockHelpers" is really a misnomer
|
||||
// since any kind of Handlebars-specific helper can live here
|
||||
HANDLEBARS.registerHelper(blockHelpers);
|
||||
if (_.isString(theme.helpers)) {
|
||||
// Register any theme-provided custom helpers...
|
||||
|
||||
// Normalize "theme.helpers" (string or array) to an array
|
||||
theme.helpers = [theme.helpers];
|
||||
}
|
||||
if (_.isArray(theme.helpers)) {
|
||||
@ -53,14 +57,14 @@ Template helper definitions for Handlebars.
|
||||
slash = require('slash');
|
||||
curGlob = null;
|
||||
try {
|
||||
_.each(theme.helpers, function(fGlob) {
|
||||
_.each(theme.helpers, function(fGlob) { // foreach theme.helpers entry
|
||||
var files;
|
||||
curGlob = fGlob;
|
||||
fGlob = path.join(theme.folder, fGlob);
|
||||
files = glob.sync(slash(fGlob));
|
||||
if (files.length > 0) {
|
||||
_.each(files, function(f) {
|
||||
HANDLEBARS.registerHelper(require(f));
|
||||
curGlob = fGlob; // ..cache in case of exception
|
||||
fGlob = path.join(theme.folder, fGlob); // ..make relative to theme
|
||||
files = glob.sync(slash(fGlob)); // ..expand the glob
|
||||
if (files.length > 0) { // ..guard against empty glob
|
||||
_.each(files, function(f) { // ..loop over concrete paths
|
||||
HANDLEBARS.registerHelper(require(f)); // ..register the path
|
||||
});
|
||||
} else {
|
||||
throw {
|
||||
@ -70,8 +74,8 @@ Template helper definitions for Handlebars.
|
||||
};
|
||||
}
|
||||
});
|
||||
} catch (_error) {
|
||||
ex = _error;
|
||||
} catch (error) {
|
||||
ex = error;
|
||||
throw {
|
||||
fluenterror: HMS.themeHelperLoad,
|
||||
inner: ex,
|
||||
@ -82,6 +86,12 @@ Template helper definitions for Handlebars.
|
||||
}
|
||||
};
|
||||
|
||||
// [^1]: This little bit of acrobatics ensures that our generic helpers are
|
||||
// called as generic helpers, not as Handlebars-specific helpers. This allows
|
||||
// them to be used in other templating engines, like Underscore. If you need a
|
||||
// Handlebars-specific helper with normal Handlebars context and options, put it
|
||||
// in block-helpers.coffee.
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=handlebars-helpers.js.map
|
||||
|
16
dist/helpers/underscore-helpers.js
vendored
16
dist/helpers/underscore-helpers.js
vendored
@ -1,11 +1,9 @@
|
||||
|
||||
/**
|
||||
Template helper definitions for Underscore.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module handlebars-helpers.js
|
||||
*/
|
||||
|
||||
(function() {
|
||||
/**
|
||||
Template helper definitions for Underscore.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module handlebars-helpers.js
|
||||
*/
|
||||
var HANDLEBARS, _, helpers;
|
||||
|
||||
HANDLEBARS = require('handlebars');
|
||||
@ -14,12 +12,10 @@ Template helper definitions for Underscore.
|
||||
|
||||
helpers = require('./generic-helpers');
|
||||
|
||||
|
||||
/**
|
||||
Register useful Underscore helpers.
|
||||
@method registerHelpers
|
||||
*/
|
||||
|
||||
*/
|
||||
module.exports = function(theme, opts, cssInfo, ctx, eng) {
|
||||
helpers.theme = theme;
|
||||
helpers.opts = opts;
|
||||
|
Reference in New Issue
Block a user