1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-12-23 05:37:23 +00:00

Introduce has/hasSection helpers.

This commit is contained in:
hacksalot 2016-01-05 00:03:54 -05:00
parent 219209c6ca
commit 4c31c96891

View File

@ -11,6 +11,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
, H2W = require('../utils/html-to-wpml')
, XML = require('xml-escape')
, moment = require('moment')
, LO = require('lodash')
, _ = require('underscore')
, unused = require('../utils/string');
@ -28,6 +29,35 @@ Generic template helper definitions for HackMyResume / FluentCV.
return moment ? moment( datetime ).format( format ) : datetime;
},
/**
Return true if the section is present on the resume and has at least one
element.
@method hasSection
*/
hasSection: function( title, options ) {
title = title.trim().toLowerCase();
var obj = LO.get( this.r, title );
if( _.isArray( obj ) ) {
return obj.length ? options.fn(this) : undefined;
}
else if( _.isObject( obj )) {
return ( (obj.history && obj.history.length) ||
( obj.sets && obj.sets.length ) ) ?
options.fn(this) : undefined;
}
},
/**
Return true if the context has the property or subpropery.
@method has
*/
has: function( title, options ) {
title = title && title.trim().toLowerCase();
if( LO.get( this.r, title ) ) {
return options.fn(this);
}
},
/**
Generic template helper function to display a user-overridable section
title for a FRESH resume theme. Use this in lieue of hard-coding section