linkedin / linkedin/dustjs

Passing params down template/partial levels

Open
#196 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.9k
Forks
461
PR merge metrics
No merged PRs in 30d

Description

I have an issue where a partial causes a body function to call it's self recursively causing Chrome and Firefox to throw a 'RangeError: Maximum call stack size exceeded'.

This is the hierarchy of partials I have:
# parent template:

```
{>"start_to_end_date" label="Dates:" name="propertydates" id="propertydates" value="" type="text" size="input-small" data="data-required='required'"/}
```
# start_to_end_date

```
{>"input_text" id="{id}x"/}
```

_note: {id} is from first template_
# input_text

```

```

_note: {id} is from start_to_end_date_

I have debugged the code and found that at the point where {id} is passed from start_to_end_date into input_text it is already a body_4 function which has obviously been complied. So when {id} is read inside input_text the context key id is a function in the tail.head of body_4. So, as the context is not reset it continues passing the id of body_4, and therefore keeps calling its self until the browser throws a warning.

Sorry if I've note explained this very well, i'll try again if needs be. It could be that I'm using partial parameters in the wrong way, but I wanted to check first.

Thanks.
Rich

Contributor guide

No contributing guide indexed for this repository

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 by reproducing the recursive call with the parent template, start_to_end_date partial, and input_text partial shown in the issue. Trace how the id parameter and rendering context are passed between these levels; done should mean the nested partial renders the expected input without exhausting the browser call stack.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.