Comparing version 0.0.2 to 0.0.3
27
index.js
@@ -19,5 +19,30 @@ var regex = /(\{\{\s*\w+\s*\}\})/ | ||
Block.prototype.local = function (name, value) { | ||
var names = this.names | ||
var j | ||
for (var i in names) | ||
if (names[i] === name && names.hasOwnProperty(i)) | ||
j = i | ||
if (j == null) | ||
throw new Error('Name ' + name + ' is not defined.') | ||
delete names[j] | ||
this.blocks[j] = value || '' | ||
return this | ||
} | ||
Block.prototype.locals = function (object) { | ||
for (var name in object) | ||
if (object.hasOwnProperty(name)) | ||
this.local(name, object[name]) | ||
return this | ||
} | ||
Block.prototype.render = function (locals) { | ||
locals = locals || {} | ||
var blocks = this.blocks | ||
@@ -24,0 +49,0 @@ var names = this.names |
{ | ||
"name": "block", | ||
"description": "Block-based HTML templating", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"devDependencies": { | ||
@@ -6,0 +6,0 @@ "mocha": "*", |
8612
273