Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require context shifting #785

Open
aubelsb2 opened this issue Jun 7, 2021 · 1 comment
Open

Require context shifting #785

aubelsb2 opened this issue Jun 7, 2021 · 1 comment

Comments

@aubelsb2
Copy link

aubelsb2 commented Jun 7, 2021

Perhaps I missed something somewhere else however I can't see how to enforce going down a context without falling back on the parent node when a specified template is missing. (Unclear, yes sorry not sure how to phrase it. Here is an example:)

On
https://mustache.github.io/#demo

When I run

All items:
{{#items}}
  <li><strong>{{name}}</strong></li>
{{/items}}

All Orders:
{{#orders}}
Order: {{order}} in status {{status}}
All items:
{{#items}}
  <li><strong>{{name}}</strong></li>
{{/items}}
{{/orders}}

With this data structure:

{
  "items": [
      {"name": "red", "first": true, "url": "#Red"},
      {"name": "green", "link": true, "url": "#Green"},
      {"name": "blue", "link": true, "url": "#Blue"}
  ],
  "orders": [
    {
       "order": 1,
        "items": [
          {"name": "red", "first": true, "url": "#Red"}
        ],
       "status": "ordered"
    },
    {
       "order": 2,
       "status": "pending items"
    }
  ]
}

I get this output:

All items:
<li><strong>red</strong></li>
<li><strong>green</strong></li>
<li><strong>blue</strong></li>
All Orders:
Order: 1 in status ordered
All items:
<li><strong>red</strong></li>
Order: 2 in status pending items
All items:
<li><strong>red</strong></li>
<li><strong>green</strong></li>
<li><strong>blue</strong></li>

But I expect it to be:

All items:
<li><strong>red</strong></li>
<li><strong>green</strong></li>
<li><strong>blue</strong></li>
All Orders:
Order: 1 in status ordered
All items:
<li><strong>red</strong></li>
Order: 2 in status pending items
All items:

How do I enforce that the "child" node in "Orders" only attempts to fetch the path from the child without defaulting to the parent?

@bobthecow
Copy link

See mustache/spec#52 for a proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@bobthecow @aubelsb2 and others