Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
hashmap(engine);
list(engine);
path(engine);
is(engine);
caseSwitch(engine);
DustIntl.registerWith(engine);
youtube(engine);
dtf(engine);
log(engine);
pretty(engine);
media(engine);
split(engine);
engine.filters.base = value => base.base(basePath, value);
engine.helpers.same = (chunk, context, bodies, params) => {
if (params.key == params.val) { //eslint-disable-line eqeqeq
chunk.render(bodies.block, context);
}
};
function load(name) {
return xhr.basedGet('dust/' + name + '.js')
.then(template => {
// need to do that so we don't have to expose dust compile
/*jslint evil: true */
let loadTemplate = new Function('dust', template); //eslint-disable-line no-new-func
/*jslint evil: false */
loadTemplate(engine);
return template;
});
}
// when @eq, @lt etc are used as standalone helpers, key is required and hence check for defined
if ( typeof params.key !== "undefined") {
actualKey = dust.helpers.tap(params.key, chunk, context);
}
else if (isSelect(context)) {
actualKey = context.current().selectKey;
// supports only one of the blocks in the select to be selected
if (context.current().isResolved) {
filterOp = function() { return false; };
}
}
else {
_console.log ("No key specified for filter in:" + filterOpType + " helper ");
return chunk;
}
expectedValue = dust.helpers.tap(params.value, chunk, context);
// coerce both the actualKey and expectedValue to the same type for equality and non-equality compares
if (filterOp(coerce(expectedValue, params.type, context), coerce(actualKey, params.type, context))) {
if (isSelect(context)) {
context.current().isResolved = true;
}
// we want helpers without bodies to fail gracefully so check it first
if(body) {
return chunk.render(body, context);
}
else {
_console.log( "Missing body block in the " + filterOpType + " helper ");
return chunk;
}
}
else if (bodies['else']) {
return chunk.render(bodies['else'], context);
const striptags = require('striptags');
const summarize = (scope.require('summarize-strategy') || {summarize: text => text}).summarize;
function getDustTemplate(templatePath) {
return function dustTemplate(shape, renderer, next) {
var stream = dust.stream(templatePath, shape)
.on('data', function(data) {
renderer.write(data);
})
.on('end', next)
.on('error', function(err) {throw err;});
stream['decent-renderer'] = renderer;
};
}
dust.helpers.shape = function shapeDustHelper(chunk, context, bodies, params) {
var shapeParam = params.shape;
var theShape = shapeParam ? dust.helpers.tap(shapeParam, chunk, context) : null;
var name, tag;
var attributes = {};
// Clone the shape, so that its attributes can be changed between different
// renderings of the same shape.
// Warning: shallow copy, so weird things may still happen for object and
// array properties.
var shape = theShape ? {meta: theShape.meta, temp: theShape.temp} : null;
Object.getOwnPropertyNames(params)
.forEach(function(paramName) {
var param = dust.helpers.tap(params[paramName], chunk, context);
switch(paramName) {
case 'shape': break;
case 'name':
name = param;
include_style: false, // exclude the content of <style> tags
compact_whitespace: false // compact consecutive '\s' whitespace into single char
};
data = html_strip.html_strip(data, options).trim();
chunk.write(data);
chunk.end();
});
};
/*
* Default values for partials
*/
dust.helpers.defaultParam = function(chunk, context, bodies, params) {
var key = params.key,
value = params.value;
if(typeof context.get(key) === 'undefined') {
context.global[key] = value;
}
};
/*
* Numbers with commas
*/
dust.helpers.numberCommas = function(chunk, context, bodies, params) {
return chunk.capture(bodies.block, context, function(data, chunk){
data = data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
</style>
dust.helpers.t = function localizationDustHelper(chunk, context, bodies) {
var renderer = chunk.root['decent-renderer'];
var scope = renderer.scope;
var t = scope.require('localization') || function(s) {return s;};
var body = dust.helpers.tap(bodies.block, chunk, context);
var localizedBody = t(body);
var reTokenized = localizedBody.replace(/\[([^\]]+)]/g, '{$1}');
dust.loadSource(dust.compile(reTokenized, reTokenized));
return chunk.map(function renderLocalizedString(chunk) {
dust.render(reTokenized, context, function(err, rendered) {
chunk.end(rendered);
});
});
};
dust.helpers.style = function styleDustHelper(chunk, context, bodies, params) {
var stylesheet = dust.helpers.tap(params.name, chunk, context);
if (!stylesheet) return;
var renderer = chunk.root['decent-renderer'];
if (/^(https?:)?\/\//.test(stylesheet)) {
renderer._addExternalStyleSheet(stylesheet);
}
else {
renderer._addStyleSheet(stylesheet);
}
return chunk;
};
dust.helpers.styles = function stylesDustHelper(chunk, context, bodies, params) {
var renderer = chunk.root['decent-renderer'];
var innerRenderer = new RenderStream(renderer.scope, {
stylesheets: renderer.stylesheets
};
dust.helpers.styles = function stylesDustHelper(chunk, context, bodies, params) {
var renderer = chunk.root['decent-renderer'];
var innerRenderer = new RenderStream(renderer.scope, {
stylesheets: renderer.stylesheets
});
var html = '';
innerRenderer.on('data', function onShapeData(data) {
html += data;
});
innerRenderer._renderStyleSheets();
return chunk.write(html);
};
dust.helpers.script = function scriptDustHelper(chunk, context, bodies, params) {
var script = dust.helpers.tap(params.name, chunk, context);
if (!script) return;
var renderer = chunk.root['decent-renderer'];
if (/^(https?:)?\/\//.test(script)) {
renderer._addExternalScript(script);
}
else {
renderer._addScript(script);
}
return chunk;
};
dust.helpers.scripts = function scriptsDustHelper(chunk, context, bodies, params) {
var renderer = chunk.root['decent-renderer'];
var innerRenderer = new RenderStream(renderer.scope, {
scripts: renderer.scripts
};
dust.helpers.metas = function metasDustHelper(chunk, context, bodies, params) {
var renderer = chunk.root['decent-renderer'];
var innerRenderer = new RenderStream(renderer.scope, {
meta: renderer.meta
});
var html = '';
innerRenderer.on('data', function onShapeData(data) {
html += data;
});
innerRenderer._renderMeta();
return chunk.write(html);
};
dust.helpers.link = function linkDustHelper(chunk, context, bodies, params) {
var attributes = {};
var rel = '';
var type = '';
var href = '';
Object.getOwnPropertyNames(params).forEach(function forEachParam(attrName) {
switch(attrName) {
case 'rel':
rel = dust.helpers.tap(params.rel, chunk, context);
break;
case 'type':
type = dust.helpers.tap(params.type, chunk, context);
break;
case 'href':
href = dust.helpers.tap(params.href, chunk, context);
break;
default:
*/
dust.helpers.defaultParam = function(chunk, context, bodies, params) {
var key = params.key,
value = params.value;
if(typeof context.get(key) === 'undefined') {
context.global[key] = value;
}
};
/*
* Numbers with commas
*/
dust.helpers.numberCommas = function(chunk, context, bodies, params) {
return chunk.capture(bodies.block, context, function(data, chunk){
data = data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
chunk.write(data);
chunk.end();
});
};
dust.helpers.plural = function(chunk, context, bodies, params) {
var options = {
val: params.val,
auto: params.auto,
one: params.one,
many: params.many
}
NotificationContext.prototype.sms = function (chunk, context, bodies, params) {
this.smsMessage = dust.helpers.tap(bodies.block, chunk, context);
return chunk;
};
};
dust.helpers.scripts = function scriptsDustHelper(chunk, context, bodies, params) {
var renderer = chunk.root['decent-renderer'];
var innerRenderer = new RenderStream(renderer.scope, {
scripts: renderer.scripts
});
var html = '';
innerRenderer.on('data', function onShapeData(data) {
html += data;
});
innerRenderer._renderScripts();
return chunk.write(html);
};
dust.helpers.meta = function metaDustHelper(chunk, context, bodies, params) {
var attributes = {};
var name = null;
var value = '';
Object.getOwnPropertyNames(params).forEach(function forEachParam(attrName) {
switch(attrName) {
case 'name':
name = dust.helpers.tap(params.name, chunk, context);
break;
case 'value':
value = dust.helpers.tap(params.value, chunk, context);
break;
default:
attributes[attrName] = dust.helpers.tap(params[attrName], chunk, context);
}
});
var renderer = chunk.root['decent-renderer'];