Add a filter support to not suppress the undefined and false values in dust references ( may extend it to lists as well )
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.9k
- Forks
- 461
- PR merge metrics
- No merged PRs in 30d
Description
In some cases, we would like not to fail gracefully for missing values in the JSON, mostly for validating certain data exists at all times.
Even though this validation can be done on the "context", it is convenient to have a special filter to "enforce" that this value should always exist in the JSON
The only code to be modified is
```
Chunk.prototype.reference = function(elem, context, auto, filters) {
if (typeof elem === "function") {
elem = elem(this, context, null, {auto: auto, filters: filters});
if (elem instanceof Chunk) {
return elem;
}
}
if (!dust.isEmpty(elem)) {
return this.write(dust.filter(elem, auto, filters));
} else {
return this;
}
};
```
Related to : https://github.com/linkedin/dustjs/issues/135
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 at Chunk.prototype.reference and trace how dust.filter handles undefined and false values. Read related issue #135 for context on the requested enforcement behavior. Done means a filter can preserve those values instead of suppressing them, with list handling clarified if it is included.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100