Closed sethkinast closed 9 years ago
Here here!
auto tap? pre-compilation? tapping at all seemed kinda strange and context.get seems like a very similar
I think based on #528 there's not going to be a reasonable way to do what's right 100% of the time with an auto tap.
I can at least improve the state of things from this:
// require dustjs-helpers
foo: function(chunk, context, bodies, params) {
tapped = dust.helpers.tap(params.bar, chunk, context);
}
To this:
foo: function(chunk, context, bodies, params) {
tapped = context.tap(params.bar);
}
That is such an improvement. Well worthwhile. +1
Any way we could have a mutative context.tap(params);
? I haven't thought through it, but it seems kinda nice.
The main problem with mutating is when you want to evaluate the same param at different levels of the stack. See #528.
I've experimented with several models. I liked the idea of transforming params
into a magic getter object, but browser support and speed led me to drop that implementation for now.
This doesn't preclude us doing something more powerful in the future; it's simply a QoL improvement.
Some further improvements could be:
context.tapAllTheThingsAndGimmeANewObject()
context.magicallyConvertAllParamsToGettersThatShadowTheirOriginalProperties()
etc
Forcing use of
dust.helpers.tap
is not great. Something as basic as tapping a dust variable string to resolve its vars should be part of core.