Load strip flags from lex stream
This commit is contained in:
@@ -1,16 +1,25 @@
|
||||
import Exception from "../exception";
|
||||
|
||||
export function ProgramNode(statements, inverse) {
|
||||
export function ProgramNode(statements, inverseStrip, inverse) {
|
||||
this.type = "program";
|
||||
this.statements = statements;
|
||||
if(inverse) { this.inverse = new ProgramNode(inverse); }
|
||||
this.strip = {};
|
||||
|
||||
if(inverse) {
|
||||
this.inverse = new ProgramNode(inverse, inverseStrip);
|
||||
this.strip.right = inverseStrip.left;
|
||||
} else if (inverseStrip) {
|
||||
this.strip.left = inverseStrip.right;
|
||||
}
|
||||
}
|
||||
|
||||
export function MustacheNode(rawParams, hash, open) {
|
||||
export function MustacheNode(rawParams, hash, open, strip) {
|
||||
this.type = "mustache";
|
||||
this.hash = hash;
|
||||
this.strip = strip;
|
||||
|
||||
this.escaped = open[2] !== '{' && open[2] !== '&';
|
||||
var escapeFlag = open[3] || open[2];
|
||||
this.escaped = escapeFlag !== '{' && escapeFlag !== '&';
|
||||
|
||||
var id = this.id = rawParams[0];
|
||||
var params = this.params = rawParams.slice(1);
|
||||
@@ -29,15 +38,16 @@ export function MustacheNode(rawParams, hash, open) {
|
||||
// pass or at runtime.
|
||||
}
|
||||
|
||||
export function PartialNode(partialName, context) {
|
||||
export function PartialNode(partialName, context, strip) {
|
||||
this.type = "partial";
|
||||
this.partialName = partialName;
|
||||
this.context = context;
|
||||
this.strip = strip;
|
||||
}
|
||||
|
||||
export function BlockNode(mustache, program, inverse, close) {
|
||||
if(mustache.id.original !== close.original) {
|
||||
throw new Exception(mustache.id.original + " doesn't match " + close.original);
|
||||
if(mustache.id.original !== close.path.original) {
|
||||
throw new Exception(mustache.id.original + " doesn't match " + close.path.original);
|
||||
}
|
||||
|
||||
this.type = "block";
|
||||
@@ -45,7 +55,15 @@ export function BlockNode(mustache, program, inverse, close) {
|
||||
this.program = program;
|
||||
this.inverse = inverse;
|
||||
|
||||
if (this.inverse && !this.program) {
|
||||
this.strip = {
|
||||
left: mustache.strip.left,
|
||||
right: close.strip.right
|
||||
};
|
||||
|
||||
(program || inverse).strip.left = mustache.strip.right;
|
||||
(inverse || program).strip.right = close.strip.left;
|
||||
|
||||
if (inverse && !program) {
|
||||
this.isInverse = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user