Comparing version 1.4.1 to 1.4.2
@@ -27,2 +27,3 @@ #!/usr/bin/env node | ||
var template = razorleaf.compile(content, { | ||
debug: true, | ||
include: function(name) { | ||
@@ -29,0 +30,0 @@ return fs.readFileSync(path.join(directory, name + ".leaf"), "utf8"); |
@@ -161,4 +161,2 @@ "use strict"; | ||
var compiled = new Function("__util, data", code); | ||
if(options.debug) { | ||
@@ -168,2 +166,4 @@ console.log(code); | ||
var compiled = new Function("__util, data", code); | ||
return function(data) { | ||
@@ -213,2 +213,12 @@ return compiled(utilities, data); | ||
if(node.elif.length > 0) { | ||
node.else = { | ||
type: "if", | ||
condition: node.elif[0].condition, | ||
children: node.elif[0].children, | ||
elif: node.elif.slice(1), | ||
else: node.else | ||
}; | ||
} | ||
return { | ||
@@ -252,3 +262,3 @@ attributes: new utilities.CodeContext(), | ||
if(this.content.parts.length !== 0) { | ||
if(this.content.parts.length !== 0 || node.else) { | ||
this.parent.content.addCode("if(" + conditionName + ") {\n"); | ||
@@ -255,0 +265,0 @@ this.parent.content.addContext(this.content); |
{ | ||
"name": "razorleaf", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"main": "razorleaf.js", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -334,2 +334,3 @@ "use strict"; | ||
this.context.condition = ""; | ||
this.context.elif = []; | ||
@@ -355,2 +356,34 @@ delete this.context.name; | ||
specialBlocks.elif = { | ||
begin: function() { | ||
this.context.parent.children.pop(); | ||
this.context.type = "elif"; | ||
this.context.condition = ""; | ||
delete this.context.name; | ||
var previous = this.context.parent.children[this.context.parent.children.length - 1]; | ||
if(!previous || previous.type !== "if" || previous.else) { | ||
throw this.error("Unexpected elif"); | ||
} | ||
previous.elif.push(this.context); | ||
}, | ||
initialState: function whitespace(c) { | ||
if(c !== " ") { | ||
return this.pass(specialBlocks.elif.condition); | ||
} | ||
return whitespace; | ||
}, | ||
condition: function condition(c) { | ||
if(c === "\n") { | ||
return this.pass(states.content); | ||
} | ||
this.context.condition += c; | ||
return condition; | ||
} | ||
}; | ||
specialBlocks.else = { | ||
@@ -360,3 +393,3 @@ begin: function() { | ||
var previous = this.context.parent.children[this.context.parent.children.length - 2]; | ||
var previous = this.context.parent.children[this.context.parent.children.length - 1]; | ||
@@ -363,0 +396,0 @@ if(!previous || previous.type !== "if" || previous.else) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30880
967