From cbfe84f1a972de1908cb961504f6ce46d55e3819 Mon Sep 17 00:00:00 2001 From: Brian Kaull Date: Mon, 26 Nov 2012 11:51:53 -0800 Subject: [PATCH 1/2] Adding partial precompilation Also allowing to compile based on data getting passed in --- bin/handlebars | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bin/handlebars b/bin/handlebars index dd6e0711..1c3dd116 100755 --- a/bin/handlebars +++ b/bin/handlebars @@ -48,6 +48,16 @@ var optimist = require('optimist') 'type': 'string', 'description': 'Template root. Base value that will be stripped from template names.', 'alias': 'root' + }, + 'p' : { + 'type': 'boolean', + 'description': 'Compiling a partial template', + 'alias': 'partial' + }, + 'd' : { + 'type': 'boolean', + 'description': 'Include data when compiling', + 'alias': 'data' } }) @@ -123,7 +133,11 @@ function processTemplate(template, root) { knownHelpersOnly: argv.o }; - // Clean the template name + if (argv.data) { + options.data = true; + } + +// Clean the template name if (!root) { template = basename(template); } else if (template.indexOf(root) === 0) { @@ -133,6 +147,8 @@ function processTemplate(template, root) { if (argv.simple) { output.push(handlebars.precompile(data, options) + '\n'); + } else if (argv.partial) { + output.push('Handlebars.partials[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n'); } else { output.push('templates[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n'); } From fd0560b95124bd6d335c0bd6af907281a22d72ea Mon Sep 17 00:00:00 2001 From: Brian Kaull Date: Tue, 11 Dec 2012 10:41:50 -0800 Subject: [PATCH 2/2] Update bin/handlebars --- bin/handlebars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/handlebars b/bin/handlebars index 1c3dd116..c866ce15 100755 --- a/bin/handlebars +++ b/bin/handlebars @@ -137,7 +137,7 @@ function processTemplate(template, root) { options.data = true; } -// Clean the template name + // Clean the template name if (!root) { template = basename(template); } else if (template.indexOf(root) === 0) {