Comparing version 0.0.1 to 0.0.2
23
index.js
@@ -12,23 +12,22 @@ var regex = /(\{\{\s*\w+\s*\}\})/ | ||
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.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 | ||
} | ||
@@ -44,2 +43,2 @@ | ||
} | ||
} catch (err) {} | ||
} catch (err) {} |
{ | ||
"name": "block", | ||
"description": "Block-based HTML templating", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"devDependencies": { | ||
@@ -6,0 +6,0 @@ "mocha": "*", |
@@ -1,2 +0,2 @@ | ||
# Block.js | ||
# Block.js [![Build Status](https://travis-ci.org/funraiseme/block.png)](https://travis-ci.org/funraiseme/block) | ||
@@ -17,2 +17,10 @@ Ridiculously simple HTML templating. All it does is replaces "blocks" in your template with a local. | ||
yields: | ||
```html | ||
<div class="container"> | ||
<div class="inner"></div> | ||
</div> | ||
``` | ||
That's it. HTML templating doesn't have to be any harder. | ||
@@ -47,3 +55,3 @@ | ||
```js | ||
var template = block.read(__dirname + '/template.html') | ||
var template = block.read(__dirname + '/template.html', false) | ||
template.render({ | ||
@@ -54,3 +62,3 @@ content: '' | ||
All `minfy` does, if `true`, is `block = block.replace(/\n\s*/, '')`. | ||
All `minify` does, if `true`, is `html = html.replace(/\n\s*/, '')`. | ||
@@ -57,0 +65,0 @@ ## License |
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
64
0
8135
9
255