From 2ba23ee80da6ea230e9c35fadb9f0f3e0741107c Mon Sep 17 00:00:00 2001 From: hacksalot Date: Mon, 4 Jan 2016 16:20:48 -0500 Subject: [PATCH] Add support for user-definable section titles. Introduce a {{sectionTitle}} helper; requires theme updates. --- src/eng/generic-helpers.js | 38 ++++++++++++++++++++++++++++++++++++-- src/verbs/generate.js | 1 + 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/eng/generic-helpers.js b/src/eng/generic-helpers.js index 3ed9c10..314f263 100644 --- a/src/eng/generic-helpers.js +++ b/src/eng/generic-helpers.js @@ -28,6 +28,40 @@ Generic template helper definitions for HackMyResume / FluentCV. return moment ? moment( datetime ).format( format ) : datetime; }, + /** + Generic template helper function to display a user-overridable section + title for a FRESH resume theme. Use this in lieue of hard-coding section + titles. + + Usage: + + {{sectionTitle "sectionName"}} + {{sectionTitle "sectionName" "sectionTitle"}} + + Example: + + {{sectionTitle "Education"}} + {{sectionTitle "Employment" "Project History"}} + + @param sect_name The name of the section being title. Must be one of the + top-level FRESH resume sections ("info", "education", "employment", etc.). + @param sect_title The theme-specified section title. May be replaced by the + user. + @method sectionTitle + */ + sectionTitle: function( sname, stitle ) { + + // If not provided by the user, stitle should default to sname. ps. + // Handlebars silently passes in the options object to the last param, + // where in Underscore stitle will be null/undefined, so we check both. + stitle = (stitle && String.is(stitle)) || sname; + + // If there's a section title override, use it. + return ( this.opts.stitles && + this.opts.stitles[ sname.toLowerCase().trim() ] ) || + stitle; + }, + /** Convert inline Markdown to inline WordProcessingML. @method wpml @@ -61,7 +95,7 @@ Generic template helper definitions for HackMyResume / FluentCV. }, /** - Convert a skill level to an RGB color triplet. + Convert a skill level to an RGB color triplet. TODO: refactor @method skillColor @param lvl Input skill level. Skill level can be expressed as a string ("beginner", "intermediate", etc.), as an integer (1,5,etc), as a string @@ -77,7 +111,7 @@ Generic template helper definitions for HackMyResume / FluentCV. }, /** - Return an appropriate height. + Return an appropriate height. TODO: refactor @method lastWord */ skillHeight: function( lvl ) { diff --git a/src/verbs/generate.js b/src/verbs/generate.js index 8b34521..c16a269 100644 --- a/src/verbs/generate.js +++ b/src/verbs/generate.js @@ -55,6 +55,7 @@ Implementation of the 'generate' verb for HackMyResume. _opts.css = opts.css || 'embed'; _opts.pdf = opts.pdf; _opts.wrap = opts.wrap || 60; + _opts.stitles = opts.sectionTitles; // If two or more files are passed to the GENERATE command and the TO // keyword is omitted, the last file specifies the output file.