Socket
Socket
Sign inDemoInstall

dust-usecontent-helper

Package Overview
Dependencies
0
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0-2 to 4.0.0-3

.nyc_output/5577.json

32

index.js

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

ctx = ctx.push({ intl: { messages: content, bundle: params.bundle } });
hackGibson(ctx, content, params.bundle);
bodies.block(chunk, ctx).end();

@@ -37,33 +36,2 @@ }

function hackGibson(ctx, content, bundle) {
var oldShiftBlocks = ctx.shiftBlocks;
var oldPush = ctx.push;
ctx.shiftBlocks = function(locals) {
return oldShiftBlocks.call(this, objMap(locals, function (l) {
return wrapBlock(l, content, bundle);
}));
};
ctx.push = function(head, idx, len) {
var newCtx = oldPush.apply(this, arguments);
hackGibson(newCtx, content, bundle);
return newCtx;
};
}
function wrapBlock(block, content, bundle) {
return function (chunk, ctx) {
ctx = ctx.push({intl: { messages: content, bundle: bundle }});
return block(chunk, ctx);
}
}
function objMap(obj, fn) {
var n = {};
Object.keys(obj).forEach(function (e) {
n[e] = fn(obj[e]);
});
return n;
}
module.exports.withLoader = module.exports;

8

package.json
{
"name": "dust-usecontent-helper",
"version": "4.0.0-2",
"version": "4.0.0-3",
"description": "A dust helper to load i18n content at render time",
"main": "index.js",
"scripts": {
"test": "tape test/*.js"
"test": "nyc tap test/*.js && nyc report",
"cover": "nyc report --reporter=lcov"
},

@@ -14,4 +15,5 @@ "author": "Aria Stewart <ariastewart@paypal.com>",

"dustjs-linkedin": "~2.7.1",
"tape": "^3.0.0"
"nyc": "^2.3.0",
"tap": "^1.2.0"
}
}
"use strict";
var test = require('tape');
var test = require('tap').test;
var dustjs = require('dustjs-linkedin');
var messages = require('dust-message-helper');
var helper = require('../');
test('Does helper load?', function (t) {
require('../index')(function(locality, bundle, cont) {
helper(function(locality, bundle, cont) {
}).registerWith(dustjs);

@@ -16,3 +17,3 @@

test('Does loader work?', function (t) {
require('../index')(function(context, bundle, cont) {
helper(function(context, bundle, cont) {
t.same(context.options.option, true);

@@ -45,6 +46,15 @@ t.pass('loader got called');

});
t.test('do empty helpers work?', function (t) {
var tmpl = dustjs.loadSource(dustjs.compile('!{@useContent bundle="test" /}!'));
dustjs.render(tmpl, dustjs.context({}, { option: true }), function (err, out) {
t.equal(out, "!!");
t.end();
});
});
});
test('bundle annotation', function (t) {
require('../index')(function(context, bundle, cont) {
helper(function(context, bundle, cont) {
t.same(context.options.option, true);

@@ -67,10 +77,8 @@ t.pass('loader got called');

t.test('does loader get called?', function (t) {
dustjs.loadSource(dustjs.compile('{@useContent bundle="test"}{@wompwomp/}{/useContent}', 'test'));
dustjs.render('test', dustjs.context({}, { option: true }), function (err, out) {
t.error(err);
t.equal(out, "test");
t.end();
});
dustjs.loadSource(dustjs.compile('{@useContent bundle="test"}{@wompwomp/}{/useContent}', 'test'));
dustjs.render('test', dustjs.context({}, { option: true }), function (err, out) {
t.error(err);
t.equal(out, "test");
t.end();
});
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc