Skip to content

Instantly share code, notes, and snippets.

View jessegavin's full-sized avatar

Jesse Gavin jessegavin

View GitHub Profile
@jessegavin
jessegavin / capture-helper-params.js
Created April 28, 2016 02:14 — forked from innerfunction/capture-helper-params.js
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