1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-02 20:37:08 +01:00
This commit is contained in:
hacksalot
2016-02-11 11:48:44 -05:00
parent aaa5e1fc1f
commit 317a250917
7 changed files with 203 additions and 297 deletions

View File

@ -38,18 +38,21 @@ Generic template helper definitions for HackMyResume / FluentCV.
GenericHelpers = module.exports = {
/**
Convert the input date to a specified format through Moment.js.
If date is invalid, will return the time provided by the user,
or default to the fallback param or 'Present' if that is set to true
@method formatDate
Display a formatted date with optional fallback text.
Convert the input date to the specified format through Moment.js. If date is
valid, return the formatted date string. If date is null, undefined, or other
falsy value, return the value of the 'fallback' parameter, if specified, or
null if no fallback was specified. If date is invalid, but not null/undefined/
falsy, return it as-is.
*/
formatDate: function(datetime, format, fallback) {
formatDate: function(datetime, dtFormat, fallback) {
var momentDate;
if (moment) {
momentDate = moment(datetime);
if (momentDate.isValid()) {
return momentDate.format(format);
}
if (dtFormat == null) {
dtFormat = 'YYYY-MM';
}
momentDate = moment(datetime);
if (momentDate.isValid()) {
return momentDate.format(dtFormat);
}
return datetime || (typeof fallback === 'string' ? fallback : (fallback === true ? 'Present' : null));
},
@ -99,8 +102,8 @@ Generic template helper definitions for HackMyResume / FluentCV.
},
/**
Return true if the section is present on the resume and has at least one
element.
Block-level helper. Emit the enclosed content if the resume has a section with
the specified name. Otherwise, emit an empty string ''.
@method section
*/
section: function(title, options) {
@ -292,7 +295,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
},
/**
Return true if the context has the property or subpropery.
Emit the enclosed content if the resume has the named property or subproperty.
@method has
*/
has: function(title, options) {
@ -328,10 +331,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
return (this.opts.stitles && this.opts.stitles[sname.toLowerCase().trim()]) || stitle;
},
/**
Convert inline Markdown to inline WordProcessingML.
@method wpml
*/
/** Convert inline Markdown to inline WordProcessingML. */
wpml: function(txt, inline) {
if (!txt) {
return '';