From a935fe7dc25f1bb49aa873b73dc17a0a74739eee Mon Sep 17 00:00:00 2001 From: hacksalot Date: Thu, 21 Jan 2016 23:39:30 -0500 Subject: [PATCH] Introduce {{fontFace}} helper. --- src/helpers/generic-helpers.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/helpers/generic-helpers.js b/src/helpers/generic-helpers.js index 836412f..4b38161 100644 --- a/src/helpers/generic-helpers.js +++ b/src/helpers/generic-helpers.js @@ -20,10 +20,7 @@ Generic template helper definitions for HackMyResume / FluentCV. , _ = require('underscore') , unused = require('../utils/string'); - /** - Generic template helper function definitions. - @class GenericHelpers - */ + /** Generic template helper function definitions. */ var GenericHelpers = module.exports = { /** @@ -77,9 +74,30 @@ Generic template helper definitions for HackMyResume / FluentCV. } }, - fontFace: function( styleName ) { + /** + Emit the font face (such as 'Helvetica' or 'Calibri') associated with the + provided key. + @param key {String} A named style from the "fonts" section of the theme's + theme.json file. For example: 'default' or 'heading1'. + */ + fontFace: function( key ) { + if( key && key.trim() && GenericHelpers.theme.fonts ) { + var fontSpec = GenericHelpers.theme.fonts[ key ]; + if( fontSpec ) + return String.is( fontSpec ) ? fontSpec : fontSpec[0]; + } + _reportError( HMSTATUS.invalidHelperUse, { helper: 'fontFace' } ); + return ''; + }, + + /** + Emit a comma-delimited list of font names suitable associated with the + provided key. + @param styleName + */ + fontList: function( key ) { var ret = ''; - var fontSpec = GenericHelpers.theme.fonts[ styleName ]; + var fontSpec = GenericHelpers.theme.fonts[ key ]; if( _.isArray( fontSpec ) ) { fontSpec = fontSpec.map( function(ff) { return "'" + ff + "'";