From 896b7055c1e8c0a198bfab7c3e80b9ac31afc8bd Mon Sep 17 00:00:00 2001 From: hacksalot Date: Fri, 29 Jan 2016 15:50:21 -0500 Subject: [PATCH] Fix issue with undefined sections. Fixes #127. --- dist/helpers/generic-helpers.js | 20 ++++++++++++-------- src/helpers/generic-helpers.coffee | 15 +++++++++------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/dist/helpers/generic-helpers.js b/dist/helpers/generic-helpers.js index ec88575..f2e1fab 100644 --- a/dist/helpers/generic-helpers.js +++ b/dist/helpers/generic-helpers.js @@ -108,18 +108,22 @@ Generic template helper definitions for HackMyResume / FluentCV. @method section */ section: function(title, options) { - var obj; + var obj, ret; title = title.trim().toLowerCase(); obj = LO.get(this.r, title); - if (_.isArray(obj)) { - if (obj.length) { - return options.fn(this); - } else { - return void 0; + ret = ''; + if (obj) { + if (_.isArray(obj)) { + if (obj.length) { + ret = options.fn(this); + } + } else if (_.isObject(obj)) { + if ((obj.history && obj.history.length) || (obj.sets && obj.sets.length)) { + ret = options.fn(this); + } } - } else if (_.isObject(obj)) { - return (obj.history && obj.history.length) || (obj.sets && obj.sets.length ? options.fn(this) : void 0); } + return ret; }, /** diff --git a/src/helpers/generic-helpers.coffee b/src/helpers/generic-helpers.coffee index fc8836c..6e7c9e3 100644 --- a/src/helpers/generic-helpers.coffee +++ b/src/helpers/generic-helpers.coffee @@ -74,12 +74,15 @@ GenericHelpers = module.exports = section: ( title, options ) -> title = title.trim().toLowerCase() obj = LO.get this.r, title - if _.isArray obj - return if obj.length then options.fn(this) else undefined; - else if _.isObject obj - return (obj.history && obj.history.length) || - if ( obj.sets && obj.sets.length ) - then options.fn(this) else undefined + ret = '' + if obj + if _.isArray obj + if obj.length + ret = options.fn @ + else if _.isObject obj + if (obj.history && obj.history.length) || (obj.sets && obj.sets.length) + ret = options.fn @ + ret ###* Emit the size of the specified named font.