1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 16:30:11 +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') , H2W = require('../utils/html-to-wpml')
, XML = require('xml-escape') , XML = require('xml-escape')
, moment = require('moment') , moment = require('moment')
, LO = require('lodash')
, _ = require('underscore') , _ = require('underscore')
, unused = require('../utils/string'); , unused = require('../utils/string');
@ -28,6 +29,35 @@ Generic template helper definitions for HackMyResume / FluentCV.
return moment ? moment( datetime ).format( format ) : datetime; 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 Generic template helper function to display a user-overridable section
title for a FRESH resume theme. Use this in lieue of hard-coding section title for a FRESH resume theme. Use this in lieue of hard-coding section