Add support for non-plain-object models
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.9k
- Forks
- 461
- PR merge metrics
- No merged PRs in 30d
Description
Dust takes for granted that the objects passed as models are plain native objects, i.e. Object, Array, String, Number etc.
In some applications, the model is represented by custom objects that expose accessors to read properties. This is mainly done to support data binding and observers that don't use the deprecated Object.observe API, e.g. EmberJS/SproutCore's model objects.
I have my custom UI library that uses exactly this approach exposing in ObservableObject, ObservableCollection the .prop() method to read/write property/path values: e.g.
```
myObservableObject.prop('my.path.to.string') //read
myObservableObject.prop('my.path.to.string', 'new value') //write
```
Other templating libraries, like Handlebars, allow the extension of the renderer's properties access method.
It would be great seeing this piece of functionality implemented in dustjs, with some form of delegation.
At the moment, I'm brutally embedding the desired logic in the dust.js file, in my fork.
Cheers
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing dust.js and the model property-access logic described in the issue, then compare it with the custom accessor approach using prop(). Define how delegation should work for custom objects and nested paths. Done means Dust can render models with accessor-based properties without requiring forked logic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100