diff options
Diffstat (limited to 'lib/handlebars/compiler/helpers.js')
-rw-r--r-- | lib/handlebars/compiler/helpers.js | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/handlebars/compiler/helpers.js b/lib/handlebars/compiler/helpers.js index d236f7f..d9b7b14 100644 --- a/lib/handlebars/compiler/helpers.js +++ b/lib/handlebars/compiler/helpers.js @@ -12,12 +12,32 @@ export function stripComment(comment) { .replace(/-?-?~?\}\}$/, ''); } +export function prepareRawBlock(openRawBlock, content, close, locInfo) { + /*jshint -W040 */ + if (openRawBlock.sexpr.id.original !== close) { + var errorNode = { + firstLine: openRawBlock.sexpr.firstLine, + firstColumn: openRawBlock.sexpr.firstColumn + }; + + throw new Exception(openRawBlock.sexpr.id.original + " doesn't match " + close, errorNode); + } + + var program = new this.ProgramNode([content], {}, locInfo); -export function prepareBlock(mustache, program, inverseAndProgram, close, inverted, locInfo) { + return new this.BlockNode(openRawBlock.sexpr, program, undefined, undefined, locInfo); +} + +export function prepareBlock(openBlock, program, inverseAndProgram, close, inverted, locInfo) { /*jshint -W040 */ // When we are chaining inverse calls, we will not have a close path - if (close && close.path && (mustache.sexpr.id.original !== close.path.original)) { - throw new Exception(mustache.sexpr.id.original + ' doesn\'t match ' + close.path.original, mustache); + if (close && close.path && openBlock.sexpr.id.original !== close.path.original) { + var errorNode = { + firstLine: openBlock.sexpr.firstLine, + firstColumn: openBlock.sexpr.firstColumn + }; + + throw new Exception(openBlock.sexpr.id.original + ' doesn\'t match ' + close.path.original, errorNode); } // Safely handle a chained inverse that does not have a non-conditional inverse @@ -40,7 +60,7 @@ export function prepareBlock(mustache, program, inverseAndProgram, close, invert } var strip = { - left: mustache.strip.left, + left: openBlock.strip.left, right: close.strip.right, // Determine the standalone candiacy. Basically flag our content as being possibly standalone @@ -49,7 +69,7 @@ export function prepareBlock(mustache, program, inverseAndProgram, close, invert closeStandalone: isPrevWhitespace((firstInverse || program).statements) }; - if (mustache.strip.right) { + if (openBlock.strip.right) { omitRight(program.statements, null, true); } @@ -81,9 +101,9 @@ export function prepareBlock(mustache, program, inverseAndProgram, close, invert } if (inverted) { - return new this.BlockNode(mustache, inverse, program, strip, locInfo); + return new this.BlockNode(openBlock.sexpr, inverse, program, strip, locInfo); } else { - return new this.BlockNode(mustache, program, inverse, strip, locInfo); + return new this.BlockNode(openBlock.sexpr, program, inverse, strip, locInfo); } } |