handlebars-lang / handlebars-lang/handlebars.js

Add hook to call on missing properties

Open
#1,435 12 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
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:

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

Open the contributing guide

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.