Open cleverplatypus opened 7 years ago
Hm, can you explain more detailed what exactly you want to achieve?
As far as I understand your goal, out of box Nunjucks doesn't have nothing to support this. But you always can pass any methods to Nunjucks environment with addGlobal, and they will appear in your templates as functions, like {{ getMyProps('path.to.props') }}
.
Hi, I'm looking for an alternative to dustjs for my custom mvc library. Nunjucks seems to satisfy the requirements.
However, one feature that I could not find is a way to proxy the objects to be passed as context to support custom getters/setters. My library uses the ObservableObject class to update views when the model changes. It exposes the .prop(chain, [new_value]) to deep-access properties and notify any observers about value changes.
This seems to be supported in Handlebars as it is used by SproutCore and Emberjs with their Model classes. At the moment I have to call .toPlainObject() on my models before rendering with dustjs, and this creates unnecessary data duplication.
Is there a way to extend Nunjucks to support this feature?