Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "block", | ||
"description": "Block-based HTML templating", | ||
"version": "0.0.1", | ||
"version": "0.0.4", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": [ |
{ | ||
"name": "block", | ||
"description": "Block-based HTML templating", | ||
"version": "0.0.1", | ||
"repo": "funraiseme/block", | ||
"version": "0.0.4", | ||
"main": "index.js", | ||
"scripts": [ | ||
"index.js" | ||
] | ||
} | ||
], | ||
"license": "WTFPL" | ||
} |
@@ -215,23 +215,47 @@ ;(function(){ | ||
for (var i = 0, l = blocks.length; i < l; i++) { | ||
var block = blocks[i] | ||
if (regex.test(block)) { | ||
var block | ||
for (var i = 0, l = blocks.length; i < l; i++) | ||
if (regex.test(block = blocks[i])) | ||
names[i] = block.match(/(\w+)/)[0] | ||
blocks[i] = null | ||
} | ||
} | ||
} | ||
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 | ||
var names = this.names | ||
var l = blocks.length | ||
var buf = new Array(l) | ||
var html = '' | ||
var name | ||
for (var i = 0; i < l; i++) | ||
buf[i] = (name = names[i]) ? locals[name] : blocks[i] | ||
for (var i = 0, l = blocks.length; i < l; i++) | ||
html += (name = names[i]) ? locals[name] : blocks[i] | ||
return buf.join('') | ||
return html | ||
} | ||
@@ -245,8 +269,6 @@ | ||
var string = fs.readFileSync(filename, 'utf8') | ||
if (minify) | ||
string = string.replace(/\n\s*/g, '') | ||
return new Block(string) | ||
return new Block(minify ? string.replace(/\n\s*/g, '') : string) | ||
} | ||
} catch (err) {} | ||
}); | ||
@@ -260,3 +282,3 @@ require.alias("block/index.js", "block/index.js"); | ||
} else { | ||
window["block"] = require("block"); | ||
this["block"] = require("block"); | ||
}})(); |
{ | ||
"name": "block", | ||
"description": "Block-based HTML templating", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"devDependencies": { | ||
@@ -11,3 +11,18 @@ "mocha": "*", | ||
"test": "make test" | ||
} | ||
}, | ||
"author": { | ||
"name": "Jonathan Ong", | ||
"email": "me@jongleberry.com", | ||
"url": "http://jongleberry.com", | ||
"twitter": "https://twitter.com/jongleberry" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/funraiseme/block.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/funraiseme/block/issues", | ||
"email": "me@jongleberry.com" | ||
}, | ||
"license": "WTFPL" | ||
} |
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
9479
0
289
1
7