handlebars-lang / handlebars-lang/handlebars.js

Add source location to HelperOptions

Open
#1,726 0 comments 2 reactions 0 assignees View on GitHub
feature
Dominant language
JavaScript
Stars
18.7k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

The `options` object passed to a helper contains more information than in the type `HelperOptions`, specifically `name`, `loc` and `lookupProperty`. It's easy enough to add these to the type definition:

```typescript
name: string
loc: {
start: hbs.AST.Position
end: hbs.AST.Position
}
lookupProperty: (object: unknown, propertyName: string) => unknown
```

But the `loc` property isn't a full `SourceLocation`. It's missing the `source: string` property, which I hope will identify the filename of the current template. It would be fantastic to add that property so that a `helperMissing` helper can produce more useful output!

Contributor guide

Open the contributing guide

Research direction

Start by locating the HelperOptions type definition and the code that passes the options object to helpers. Read how loc and SourceLocation are currently represented, then add the requested source information so helperMissing can identify the template filename and verify the resulting helper options behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Feature
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.