You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

stream-handlebars

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-handlebars - npm Package Compare versions

Comparing version

to
0.1.2

11

lib/stream-handlebars.js

@@ -5,2 +5,3 @@ "use strict";

var handlebarsMain = require("handlebars");
var o = require("object-tools");

@@ -38,2 +39,3 @@ /**

@param [options.objectMode] {object} - set to true if you wish you pass in the data as an object
@param [options.data] {object} - default data object
@return {external:Transform}

@@ -49,3 +51,3 @@ */

this.buf = new Buffer(0);
this.options = options;
this.options = options || {};
this.template = template;

@@ -79,2 +81,9 @@ }

try {
if (Array.isArray(data)){
for (var prop in this.options.data){
data[prop] = this.options.data[prop];
}
} else {
data = o.extend(this.options.data, data);
}
var result = handlebars.compile(this.template, this.options)(data);

@@ -81,0 +90,0 @@ this.push(result);

7

package.json
{
"name": "stream-handlebars",
"author": "Lloyd Brookes <75pound@gmail.com>",
"version": "0.1.1",
"version": "0.1.2",
"description": "Extends handlebars with a streaming interface for .compile()",

@@ -20,3 +20,3 @@ "repository": "https://github.com/75lb/stream-handlebars.git",

"scripts": {
"test": "tape test/*.js",
"test": "tape test/*.js |tap-spec",
"lint": "jshint lib/*.js bin/*.js test/*.js; echo",

@@ -26,3 +26,4 @@ "docs": "jsdoc2md -t jsdoc2md/README.hbs -l js lib/*.js > README.md; echo"

"dependencies": {
"handlebars": "^3.0.0"
"handlebars": "^3.0.0",
"object-tools": "^1.2.1"
},

@@ -29,0 +30,0 @@ "devDependencies": {

@@ -23,2 +23,16 @@ var test = require("tape");

test("text interface with default data", function(t){
t.plan(1);
var data = '{ "message": "test, yeah?" }';
var template = "result {{one}}: {{message}}";
var compileStream = streamHandlebars.createCompileStream(template, { data: { one: 1 }});
compileStream.on("readable", function(){
var chunk = this.read();
if (chunk){
t.strictEqual(chunk.toString(), "result 1: test, yeah?");
}
})
compileStream.end(data);
});
test("objectMode", function(t){

@@ -25,0 +39,0 @@ t.plan(1);