Skip to content

Instantly share code, notes, and snippets.

@innerfunction
innerfunction / capture-helper-params.js
Created August 16, 2013 18:20
Node.js module for capturing parameter values being passed to a dust.js helper. For example, if calling a helper {@Helper p1="{p1}" p2="{p2}"/}, this code will resolve values for p1 and p2 in a fully asynchronous manner before calling the helper function. Use the wrapper function as: var wrapper = require('./capture-helper-params'); helpers['myh…
// Capture templated parameter values passed to a dust.js helper function.
function captureParams(chunk, context, params, cb) {
// Object for recording resolved parameter values.
var values = {};
// Capture a single parameter value.
// @param {name} The parameter name.
// @param {next} Next step in the capture chain.
function capture( name, next ) {
return function( chunk ) {
// If the parameter value is a function then it is a dust.js template that needs to be
@innerfunction
innerfunction / capture-params.js
Created August 16, 2013 18:17
Node.js module for capturing parameter values being passed to a dust.js helper. For example, if calling a helper {@Helper p1="{p1}" p2="{p2}"/}, this code will resolve values for p1 and p2 in a fully asynchronous manner before calling the helper function.
// Capture templated parameter values passed to a dust.js helper function.
function captureParams(chunk, context, params, cb) {
// Object for recording resolved parameter values.
var values = {};
// Capture a single parameter value.
// @param {name} The parameter name.
// @param {next} Next step in the capture chain.
function capture( name, next ) {
return function( chunk ) {
// If the parameter value is a function then it is a dust.js template that needs to be