mirror of
				https://github.com/JuanCanham/HackMyResume.git
				synced 2025-10-30 20:57:26 +00:00 
			
		
		
		
	Introduce has/hasSection helpers.
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user