1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 16:30:11 +00:00

Introduce {{dateRange}} and {{camelCase}} helpers.

This commit is contained in:
hacksalot 2016-01-05 04:59:51 -05:00
parent d658a069cd
commit 6a61989eb4

View File

@ -29,6 +29,26 @@ Generic template helper definitions for HackMyResume / FluentCV.
return moment ? moment( datetime ).format( format ) : datetime; return moment ? moment( datetime ).format( format ) : datetime;
}, },
/**
Format a from/to date range.
@method dateRange
*/
dateRange: function( obj, fmt, sep, options ) {
fmt = (fmt && String.is(fmt) && fmt) || 'YYYY-MM';
sep = (sep && String.is(sep) && sep) || ' — ';
if( obj.safe ) {
var dateA = (obj.safe.start && obj.safe.start.format(fmt)) || '';
var dateB = (obj.safe.end && obj.safe.end.format(fmt)) || '';
if( obj.safe.start && obj.safe.end ) {
return dateA + sep + dateB ;
}
else if( obj.safe.start || obj.safe.end ) {
return dateA || dateB;
}
}
return '';
},
/** /**
Return true if the section is present on the resume and has at least one Return true if the section is present on the resume and has at least one
element. element.
@ -47,6 +67,15 @@ Generic template helper definitions for HackMyResume / FluentCV.
} }
}, },
/**
Capitalize the first letter of the word.
@method section
*/
camelCase: function(val) {
val = (val && val.trim()) || '';
return val ? (val.charAt(0).toUpperCase() + val.slice(1)) : val;
},
/** /**
Return true if the context has the property or subpropery. Return true if the context has the property or subpropery.
@method has @method has