dust.js - how to write some variable(name and value) in dust template using helper -
i have client side dust template , corresponding helper.
helper :
function(chunk, context, bodies, params) { };
now want write key value pair(from helper) can read in dust template.
e.g.if write (k,v) in helper, in dust template
{k}
should output 'v'
thanks,
shantanu
a helper in dust receives current chunk
, context
. can push new values onto context stack, , call chunk.render()
.
{ "helper": function(chunk, context, bodies, params) { var obj = { "k": "value" }; return chunk.render(bodies.block, context.push(obj)); } }
here, rendering default body (bodies.block
), using existing context obj
, pushed onto context stack.
{#helper}{k}{/helper} {! k accessible inside context of helper !}
Comments
Post a Comment