linkedin / linkedin/dustjs

Add support for non-plain-object models

Open
#725 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.