Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

hbs

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hbs - npm Package Compare versions

Comparing version 2.7.0 to 2.8.0

4

History.md

@@ -0,1 +1,5 @@

# 2.8.0 (2014-12-26)
* update to handlebars 2.x
# 2.7.0 (2014-06-02)

@@ -2,0 +6,0 @@

80

lib/async.js
/// provides the async helper functionality
// global baton which contains the current
// set of deferreds
var waiter;
function Waiter() {
if (!(this instanceof Waiter)) {
return new Waiter();
}
function Waiter() {
var self = this;

@@ -54,49 +54,53 @@

// callback fn when all async helpers have finished running
// if there were no async helpers, then it will callback right away
Waiter.done = function(fn) {
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_';
// no async things called
if (!waiter) {
return fn({});
var gen_id = function() {
var res = '';
for (var i=0 ; i<8 ; ++i) {
res += alphabet[Math.floor(Math.random() * alphabet.length)];
}
waiter.done(fn);
// clear the waiter for the next template
waiter = undefined;
return res;
};
Waiter.resolve = function(fn, context) {
// we want to do async things, need a waiter for that
if (!waiter) {
waiter = new Waiter();
}
module.exports = function() {
// baton which contains the current
// set of deferreds
var waiter;
var id = '__' + gen_id() + '__';
var obj = Object.create(null);
obj.done = function done(fn) {
// no async things called
if (!waiter) {
return fn({});
}
var cur_waiter = waiter;
waiter.wait();
waiter.done(fn);
fn(context, function(res) {
cur_waiter.resolve(id, res);
});
// clear the waiter for the next template
waiter = undefined;
};
// return the id placeholder
// this will be replaced later
return id;
};
obj.resolve = function resolve(fn, context) {
// we want to do async things, need a waiter for that
if (!waiter) {
waiter = new Waiter();
}
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_';
var id = '__' + gen_id() + '__';
var gen_id = function() {
var res = '';
for (var i=0 ; i<8 ; ++i) {
res += alphabet[Math.floor(Math.random() * alphabet.length)];
}
var cur_waiter = waiter;
waiter.wait();
return res;
fn(context, function(res) {
cur_waiter.resolve(id, res);
});
// return the id placeholder
// this will be replaced later
return id;
};
return obj;
};
module.exports = Waiter;

@@ -7,16 +7,23 @@ var fs = require('fs');

var Instance = function(handlebars) {
function Instance(handlebars) {
if (!(this instanceof Instance)) {
return new Instance(handlebars);
}
// expose handlebars, allows users to use their versions
// by overriding this early in their apps
var self = this;
this.handlebars = handlebars || require('handlebars').create();
self.async = async();
self.handlebars = handlebars || require('handlebars').create();
// cache for templates, express 3.x doesn't do this for us
this.cache = {};
self.cache = {};
this.__express = middleware.bind(this);
self.__express = middleware.bind(this);
// DEPRECATED, kept for backwards compatibility
this.SafeString = this.handlebars.SafeString;
this.Utils = this.handlebars.Utils;
self.SafeString = this.handlebars.SafeString;
self.Utils = this.handlebars.Utils;
};

@@ -26,4 +33,5 @@

function middleware(filename, options, cb) {
var cache = this.cache;
var handlebars = this.handlebars;
var self = this;
var cache = self.cache;
var handlebars = self.handlebars;

@@ -58,3 +66,3 @@ // grab extension from filename

var res = template(locals, { data: data });
async.done(function(values) {
self.async.done(function(values) {
Object.keys(values).forEach(function(id) {

@@ -84,3 +92,3 @@ res = res.replace(id, values[id]);

var res = template(locals);
async.done(function(values) {
self.async.done(function(values) {
Object.keys(values).forEach(function(id) {

@@ -195,4 +203,5 @@ res = res.replace(id, values[id]);

Instance.prototype.registerAsyncHelper = function(name, fn) {
this.handlebars.registerHelper(name, function(context) {
return async.resolve(fn, context);
var self = this;
self.handlebars.registerHelper(name, function(context) {
return self.async.resolve(fn, context);
});

@@ -199,0 +208,0 @@ };

{
"name": "hbs",
"description": "Express.js template engine plugin for Handlebars",
"version": "2.7.0",
"version": "2.8.0",
"homepage": "https://github.com/donpark/hbs",

@@ -12,3 +12,3 @@ "author": "Don Park <donpark@docuverse.com> (http://blog.docuverse.com)",

"dependencies": {
"handlebars": "1.3.0",
"handlebars": "2.0.0",
"walk": "2.2.1"

@@ -25,3 +25,3 @@ },

"engines": {
"node": ">= 0.4.0"
"node": ">= 0.8.0"
},

@@ -28,0 +28,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc