dustjs
dustjs copied to clipboard
[discussion] Access the Context's index and length
( instead of pushing our own copies onto the stack )
I think anything that manually manipulates the stack directly is a smell. We already have these properties available as context.stack.index and context.stack.of. It doesn't seem to make sense to directly reach into the stack's head and manually set them there.
Instead, we can short-circuit get in these cases.
This also has the side effect of not polluting someone's context.current() with something they didn't expect to be there.
I would just like to get some discussion on this one, I'm not convinced it's correct yet.
Manually setting $idx and $len to undefined after is especially distasteful to me.
I would like to get something like this in for Dust@3 in which I don't plan on supporting IE8. Shall we make this a getter?