mirror of
				https://github.com/JuanCanham/HackMyResume.git
				synced 2025-10-31 05:07:26 +00:00 
			
		
		
		
	Update file headers.
This commit is contained in:
		| @@ -1,25 +1,59 @@ | ||||
| /** | ||||
| Handlebars template generate for FluentCV. | ||||
| @license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk. | ||||
| Definition of the HandlebarsGenerator class. | ||||
| @license MIT. Copyright (c) 2015 James Devlin / FluentDesk. | ||||
| @module handlebars-generator.js | ||||
| */ | ||||
|  | ||||
| (function() { | ||||
|  | ||||
|   var _ = require('underscore'); | ||||
|   var HANDLEBARS = require('handlebars'); | ||||
|   var FS = require('fs'); | ||||
|   var moment = require('moment'); | ||||
|   var MD = require('marked'); | ||||
|   var H2W = require('../utils/html-to-wpml'); | ||||
|  | ||||
|  | ||||
|   var _ = require('underscore') | ||||
|     , HANDLEBARS = require('handlebars') | ||||
|     , FS = require('fs') | ||||
|     , moment = require('moment') | ||||
|     , MD = require('marked') | ||||
|     , H2W = require('../utils/html-to-wpml'); | ||||
|  | ||||
|  | ||||
|  | ||||
|   /** | ||||
|   Perform template-based resume generation using Handlebars.js. | ||||
|   @method generate | ||||
|   */ | ||||
|   module.exports = function( json, jst, format, cssInfo, opts, theme ) { | ||||
|  | ||||
|     // Pre-compile any partials present in the theme. | ||||
|     _.each( theme.partials, function( el ) { | ||||
|       var tplData = FS.readFileSync( el.path, 'utf8' ); | ||||
|       var compiledTemplate = HANDLEBARS.compile( tplData ); | ||||
|       HANDLEBARS.registerPartial( el.name, compiledTemplate ); | ||||
|     }); | ||||
|  | ||||
|     // Register necessary helpers. | ||||
|     registerHelpers(); | ||||
|  | ||||
|     // Compile and run the Handlebars template. | ||||
|     var template = HANDLEBARS.compile(jst); | ||||
|     return template({ | ||||
|       r: json, | ||||
|       filt: opts.filters, | ||||
|       cssInfo: cssInfo, | ||||
|       headFragment: opts.headFragment || '' | ||||
|     }); | ||||
|  | ||||
|   }; | ||||
|  | ||||
|  | ||||
|  | ||||
|   /** | ||||
|   Register useful Handlebars helpers. | ||||
|   @method registerHelpers | ||||
|   */ | ||||
|   function registerHelpers() { | ||||
|  | ||||
|     // Set up a date formatting helper so we can do: | ||||
|     // {{#formatDate val 'YYYY-MM'}} | ||||
|     HANDLEBARS.registerHelper("formatDate", function(datetime, format) { | ||||
|       if( moment ) { | ||||
|         return moment( datetime ).format( format ); | ||||
| @@ -29,19 +63,23 @@ Handlebars template generate for FluentCV. | ||||
|       } | ||||
|     }); | ||||
|  | ||||
|     // Set up a Markdown-to-WordProcessingML helper so we can do: | ||||
|     // {{#wmpl val [true|false]}} | ||||
|     HANDLEBARS.registerHelper("wpml", function( txt, inline ) { | ||||
|       inline = (inline && !inline.hash) || false; | ||||
|       txt = inline ? MD(txt.trim()).replace(/^\s*<p>|<\/p>\s*$/gi, '') : MD(txt.trim()); | ||||
|       txt = inline ? | ||||
|         MD(txt.trim()).replace(/^\s*<p>|<\/p>\s*$/gi, '') : | ||||
|         MD(txt.trim()); | ||||
|       txt = H2W( txt.trim() ); | ||||
|       return txt; | ||||
|     }); | ||||
|  | ||||
|     // Set up a generic conditional helper so we can do: | ||||
|     // {{#compare val otherVal operator="<"}} | ||||
|     // http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/ | ||||
|     HANDLEBARS.registerHelper('compare', function(lvalue, rvalue, options) { | ||||
|  | ||||
|       if (arguments.length < 3) | ||||
|         throw new Error("Handlerbars Helper 'compare' needs 2 parameters"); | ||||
|  | ||||
|       var operator = options.hash.operator || "=="; | ||||
|       var operators = { | ||||
|           '==':       function(l,r) { return l == r; }, | ||||
| @@ -53,21 +91,13 @@ Handlebars template generate for FluentCV. | ||||
|           '>=':       function(l,r) { return l >= r; }, | ||||
|           'typeof':   function(l,r) { return typeof l == r; } | ||||
|       }; | ||||
|  | ||||
|       if (!operators[operator]) | ||||
|         throw new Error("Handlerbars Helper 'compare' doesn't know the operator "+operator); | ||||
|       var result = operators[operator](lvalue,rvalue); | ||||
|       return result ? options.fn(this) : options.inverse(this); | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|     var template = HANDLEBARS.compile(jst); | ||||
|     return template({ | ||||
|       r: json, | ||||
|       filt: opts.filters, | ||||
|       cssInfo: cssInfo, | ||||
|       headFragment: opts.headFragment || '' | ||||
|     }); | ||||
|  | ||||
|   }; | ||||
|  | ||||
| }()); | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| /** | ||||
| Underscore template generate for FluentCV. | ||||
| @license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk. | ||||
| Definition of the UnderscoreGenerator class. | ||||
| @license MIT. Copyright (c) 2015 James Devlin / FluentDesk. | ||||
| */ | ||||
|  | ||||
| (function() { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user