Comparing version 0.1.2 to 0.2.0
{ | ||
"name": "block", | ||
"description": "Block-based HTML templating", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"scripts": [ | ||
@@ -6,0 +6,0 @@ "index.js" |
25
index.js
@@ -29,23 +29,12 @@ module.exports = Block | ||
Block.prototype.render = function (locals) { | ||
if (typeof locals === 'object') { | ||
var string = this.string | ||
Object.keys(locals).forEach(function (key) { | ||
string = replace(string, key, locals[key]) | ||
}) | ||
return string | ||
} | ||
if (!locals) | ||
return this.string | ||
return this.string | ||
var string = this.string | ||
Object.keys(locals).forEach(function (key) { | ||
string = replace(string, key, locals[key]) | ||
}) | ||
return string | ||
} | ||
// Node only! | ||
try { | ||
var fs = require('fs') | ||
Block.read = function (filename, minify) { | ||
var string = fs.readFileSync(filename, 'utf8') | ||
return new Block(minify ? string.replace(/\n\s*/g, '') : string) | ||
} | ||
} catch (err) {} | ||
function replace(string, key, value) { | ||
@@ -52,0 +41,0 @@ return string.replace( |
{ | ||
"name": "block", | ||
"description": "Block-based HTML templating", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"devDependencies": { | ||
@@ -6,0 +6,0 @@ "mocha": "*", |
@@ -49,15 +49,2 @@ # Block.js [![Build Status](https://travis-ci.org/funraiseme/block.png)](https://travis-ci.org/funraiseme/block) | ||
### Block.read(file, minify) | ||
This is for nodejs only. `file` is the name of the file, `minify` strips whitespace. | ||
```js | ||
var template = block.read(__dirname + '/template.html', false) | ||
template.render({ | ||
content: '' | ||
}) | ||
``` | ||
All `minify` does, if `true`, is `html = html.replace(/\n\s*/, '')`. | ||
## License | ||
@@ -64,0 +51,0 @@ |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
3924
47
71