diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/handlebars/compiler/helpers.js | 4 | ||||
-rw-r--r-- | lib/handlebars/compiler/javascript-compiler.js | 18 | ||||
-rw-r--r-- | lib/precompiler.js | 6 |
3 files changed, 12 insertions, 16 deletions
diff --git a/lib/handlebars/compiler/helpers.js b/lib/handlebars/compiler/helpers.js index c93b811..dd32299 100644 --- a/lib/handlebars/compiler/helpers.js +++ b/lib/handlebars/compiler/helpers.js @@ -135,12 +135,12 @@ function isNextWhitespace(statements, i, isRoot) { return checkWhitespace(isRoot, statements[i+1], statements[i+2]); } -function checkWhitespace(isRoot, next1, next2, disallowIndent) { +function checkWhitespace(isRoot, next1, next2) { if (!next1) { return isRoot; } else if (next1.type === 'content') { // Check if the previous node is empty or whitespace only - if (disallowIndent ? !next1.string : /^[\s]*$/.test(next1.string)) { + if (/^[\s]*$/.test(next1.string)) { if (next2) { return next2.type === 'content' || /\n$/.test(next1.string); } else { diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js index fcd58fd..e53b4f2 100644 --- a/lib/handlebars/compiler/javascript-compiler.js +++ b/lib/handlebars/compiler/javascript-compiler.js @@ -50,7 +50,7 @@ JavaScriptCompiler.prototype = { compile: function(environment, options, context, asObject) { this.environment = environment; - this.options = options || {}; + this.options = options; this.stringParams = this.options.stringParams; this.trackIds = this.options.trackIds; this.precompile = !asObject; @@ -361,9 +361,9 @@ JavaScriptCompiler.prototype = { return ' != null ? ' + lookup + ' : ' + current; } else { // Otherwise we can use generic falsy handling - return (falsy ? ' && ' : ' != null && ') + lookup; + return ' && ' + lookup; } - }, true); + }); } }, @@ -385,7 +385,7 @@ JavaScriptCompiler.prototype = { for (var i = 0; i < len; i++) { this.replaceStack(function(current) { return ' && ' + this.nameLookup(current, parts[i], 'data'); - }, true); + }); } }, @@ -714,7 +714,7 @@ JavaScriptCompiler.prototype = { return stack; }, - replaceStack: function(callback, chain) { + replaceStack: function(callback) { var prefix = '', inline = this.isInline(), stack, @@ -731,18 +731,14 @@ JavaScriptCompiler.prototype = { if (top instanceof Literal) { // Literals do not need to be inlined - stack = top.value; + prefix = stack = top.value; usedLiteral = true; - - if (chain) { - prefix = stack; - } } else { // Get or create the current stack name for use by the inline createdStack = !this.stackSlot; var name = !createdStack ? this.topStackName() : this.incrStack(); - prefix = '(' + this.push(name) + ' = ' + top + (chain ? ')' : '),'); + prefix = '(' + this.push(name) + ' = ' + top + ')'; stack = this.topStack(); } diff --git a/lib/precompiler.js b/lib/precompiler.js index bae923c..6764022 100644 --- a/lib/precompiler.js +++ b/lib/precompiler.js @@ -60,7 +60,7 @@ module.exports.cli = function(opts) { output.push(opts.namespace); output.push(' || {};\n'); } - function processTemplate(template, root, explicit) { + function processTemplate(template, root) { var path = template, stat = fs.statSync(path); if (stat.isDirectory()) { @@ -71,7 +71,7 @@ module.exports.cli = function(opts) { processTemplate(path, root || template); } }); - } else if (explicit || extension.test(path)) { + } else { var data = fs.readFileSync(path, 'utf8'); if (opts.bom && data.indexOf('\uFEFF') === 0) { @@ -112,7 +112,7 @@ module.exports.cli = function(opts) { } opts.templates.forEach(function(template) { - processTemplate(template, opts.root, true); + processTemplate(template, opts.root); }); // Output the content |