handlebars-lang / handlebars-lang/handlebars.js
Add hook to call on missing properties
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 18.7k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
Before filing issues, please check the following points first:
- Have a look at https://github.com/wycats/handlebars.js/blob/master/CONTRIBUTING.md
- Read the FAQ at https://github.com/wycats/handlebars.js/blob/master/FAQ.md
- Use the jsfiddle-template at https://jsfiddle.net/9D88g/47/ to reproduce problems or bugs
Check out the jsfiddle at https://jsfiddle.net/fwrww8tj. What is demonstrated there is this problem: when registering a helper for catching missing keys in the data using:
Handlebars.registerHelper("helperMissing", function(context, options) { ... })
the helper function is called correctly when keys are missing on the top-level, but fails when the key is down the path in the data somewhere. Consider the following data set:
{
foo: "foo",
nested_property: {
foo: "foo"
}
}
When the template calls for {{bar}}, the function is correctly called. However, when the template calls for {{nested_property.bar}}, the helper is NOT called.
Contributor guide
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 with the jsfiddle reproduction and the Handlebars.registerHelper("helperMissing", ...) entry point, comparing top-level {{bar}} with nested {{nested_property.bar}}. Trace how missing properties are resolved and add a regression test showing the expected hook behavior for nested paths; done means the test passes and the reproduction behaves consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- handlebars, javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100