From 6a61989eb4066b1cd8ddef99ccf1db42aab3d98d Mon Sep 17 00:00:00 2001 From: hacksalot Date: Tue, 5 Jan 2016 04:59:51 -0500 Subject: [PATCH] Introduce {{dateRange}} and {{camelCase}} helpers. --- src/eng/generic-helpers.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/eng/generic-helpers.js b/src/eng/generic-helpers.js index 2113cea..a9defba 100644 --- a/src/eng/generic-helpers.js +++ b/src/eng/generic-helpers.js @@ -29,6 +29,26 @@ Generic template helper definitions for HackMyResume / FluentCV. 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 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. @method has