Comparing version 0.14.4-beta to 0.14.5-beta
@@ -219,2 +219,19 @@ "use strict"; | ||
nodeHandlers.block = function(node, context) { | ||
return { | ||
attributes: context.attributes, | ||
content: context.content, | ||
scope: context.scope, | ||
parent: context, | ||
done: function() {} | ||
}; | ||
}; | ||
nodeHandlers.extends = function(node, context) { | ||
return { | ||
parent: context, | ||
done: function() {} | ||
}; | ||
}; | ||
nodeHandlers.if = function(node, context) { | ||
@@ -221,0 +238,0 @@ var conditionName = context.scope.createName("condition"); |
{ | ||
"name": "razorleaf", | ||
"version": "0.14.4-beta", | ||
"version": "0.14.5-beta", | ||
"main": "razorleaf.js", | ||
@@ -18,3 +18,3 @@ "files": [ | ||
"devDependencies": { | ||
"optimist": "~0.4.0", | ||
"optimist": "~0.5.2", | ||
"cli-color": "~0.2.2" | ||
@@ -21,0 +21,0 @@ }, |
@@ -294,2 +294,4 @@ "use strict"; | ||
includes: [], | ||
extends: null, | ||
blocks: [], | ||
indent: -1 | ||
@@ -479,3 +481,3 @@ }; | ||
push: function() { | ||
throw parser.error("doctype element cannot have content"); | ||
throw parser.error("include element cannot have content"); | ||
} | ||
@@ -503,3 +505,60 @@ }; | ||
specialBlocks.block = { | ||
begin: function() { | ||
this.context.type = "block"; | ||
this.context.name = ""; | ||
this.root.blocks.push(this.context); | ||
}, | ||
initialState: function whitespace(c) { | ||
if(c !== " ") { | ||
return this.pass(specialBlocks.block.name); | ||
} | ||
return whitespace; | ||
}, | ||
name: function name(c) { | ||
if(c === "\n") { | ||
return this.pass(states.content); | ||
} | ||
this.context.name += c; | ||
return name; | ||
} | ||
}; | ||
specialBlocks.extends = { | ||
begin: function() { | ||
this.context.type = "extends"; | ||
if(this.root.extends !== null) { | ||
throw this.error("A template cannot extend more than one template"); | ||
} | ||
if(this.root.children.length !== 1) { | ||
throw this.error("extends must appear at the beginning of a template"); | ||
} | ||
this.root.extends = ""; | ||
delete this.context.name; | ||
}, | ||
initialState: function whitespace(c) { | ||
if(c !== " ") { | ||
return this.pass(specialBlocks.extends.template); | ||
} | ||
return whitespace; | ||
}, | ||
template: function template(c) { | ||
if(c === "\n") { | ||
return this.pass(states.content); | ||
} | ||
this.root.extends += c; | ||
return template; | ||
} | ||
}; | ||
module.exports.parse = parse; | ||
module.exports.states = states; | ||
module.exports.specialBlocks = specialBlocks; |
@@ -6,2 +6,14 @@ "use strict"; | ||
function loadExtends(tree, visited, options) { | ||
if(tree.extends) { | ||
if(visited.indexOf(tree.extends) !== -1) { | ||
throw new Error("Circular extension: ⤷ " + visited.slice(visited.indexOf(tree.extends)).join(" → ") + " ⤴"); | ||
} | ||
var extendTree = parser.parse(options.include(tree.extends)); | ||
console.log(extendTree); | ||
} | ||
} | ||
function loadIncludes(tree, visited, options) { | ||
@@ -26,2 +38,3 @@ tree.includes.forEach(function(include) { | ||
loadExtends(tree, [], options); | ||
loadIncludes(tree, [], options); | ||
@@ -28,0 +41,0 @@ |
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
24950
809