react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / handlebars / dist / amd / handlebars / compiler / helpers.js
80738 viewsdefine(1["../exception","exports"],2function(__dependency1__, __exports__) {3"use strict";4var Exception = __dependency1__["default"];56function SourceLocation(source, locInfo) {7this.source = source;8this.start = {9line: locInfo.first_line,10column: locInfo.first_column11};12this.end = {13line: locInfo.last_line,14column: locInfo.last_column15};16}1718__exports__.SourceLocation = SourceLocation;function stripFlags(open, close) {19return {20open: open.charAt(2) === '~',21close: close.charAt(close.length-3) === '~'22};23}2425__exports__.stripFlags = stripFlags;function stripComment(comment) {26return comment.replace(/^\{\{~?\!-?-?/, '')27.replace(/-?-?~?\}\}$/, '');28}2930__exports__.stripComment = stripComment;function preparePath(data, parts, locInfo) {31/*jshint -W040 */32locInfo = this.locInfo(locInfo);3334var original = data ? '@' : '',35dig = [],36depth = 0,37depthString = '';3839for(var i=0,l=parts.length; i<l; i++) {40var part = parts[i].part;41original += (parts[i].separator || '') + part;4243if (part === '..' || part === '.' || part === 'this') {44if (dig.length > 0) {45throw new Exception('Invalid path: ' + original, {loc: locInfo});46} else if (part === '..') {47depth++;48depthString += '../';49}50} else {51dig.push(part);52}53}5455return new this.PathExpression(data, depth, dig, original, locInfo);56}5758__exports__.preparePath = preparePath;function prepareMustache(path, params, hash, open, strip, locInfo) {59/*jshint -W040 */60// Must use charAt to support IE pre-1061var escapeFlag = open.charAt(3) || open.charAt(2),62escaped = escapeFlag !== '{' && escapeFlag !== '&';6364return new this.MustacheStatement(path, params, hash, escaped, strip, this.locInfo(locInfo));65}6667__exports__.prepareMustache = prepareMustache;function prepareRawBlock(openRawBlock, content, close, locInfo) {68/*jshint -W040 */69if (openRawBlock.path.original !== close) {70var errorNode = {loc: openRawBlock.path.loc};7172throw new Exception(openRawBlock.path.original + " doesn't match " + close, errorNode);73}7475locInfo = this.locInfo(locInfo);76var program = new this.Program([content], null, {}, locInfo);7778return new this.BlockStatement(79openRawBlock.path, openRawBlock.params, openRawBlock.hash,80program, undefined,81{}, {}, {},82locInfo);83}8485__exports__.prepareRawBlock = prepareRawBlock;function prepareBlock(openBlock, program, inverseAndProgram, close, inverted, locInfo) {86/*jshint -W040 */87// When we are chaining inverse calls, we will not have a close path88if (close && close.path && openBlock.path.original !== close.path.original) {89var errorNode = {loc: openBlock.path.loc};9091throw new Exception(openBlock.path.original + ' doesn\'t match ' + close.path.original, errorNode);92}9394program.blockParams = openBlock.blockParams;9596var inverse,97inverseStrip;9899if (inverseAndProgram) {100if (inverseAndProgram.chain) {101inverseAndProgram.program.body[0].closeStrip = close.strip;102}103104inverseStrip = inverseAndProgram.strip;105inverse = inverseAndProgram.program;106}107108if (inverted) {109inverted = inverse;110inverse = program;111program = inverted;112}113114return new this.BlockStatement(115openBlock.path, openBlock.params, openBlock.hash,116program, inverse,117openBlock.strip, inverseStrip, close && close.strip,118this.locInfo(locInfo));119}120121__exports__.prepareBlock = prepareBlock;122});123124