Function to return JS object containing EJS template bindings structure.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.1k
- Forks
- 846
- PR merge metrics
- No merged PRs in 30d
Description
I believe this issue has already been raised previously here, but it seems the original question may have been misunderstood.
I've also encountered this problem. In my use case, I want to generate a request schema based on the bindings within an EJS template. Ideally, I need a function that returns an object representing the variables used in the template.
For example, given this template:
<p><%- SomeRandomVar %></p>
<p><%- User.FirstName %></p>
<% for (let badge of User.Badges) { %>
<p><%- badge.Name %></p>
<% } %>
I would expect something like:
{
"SomeRandomVar": "string",
"User": {
"Badges": [
{
"Name": "string"
}
]
}
}
I don't need a fully fleshed out JSON schema but just getting some of the variable names from within the template would be a good start. Is there anything built into EJS already that provides this sort of functionality or would this be a new feature request?
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
No implementation file or test is named. Start by reading the related issue #683 and inspecting EJS's existing public API for template parsing or compilation; the work would be complete when a documented function can extract template variable names or structure, with behavior for nested properties and loop variables covered by tests.
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
- Needs clarification
- Newbie friendliness
- 28/100