Skip to content

Conditionals affect ../ path segment behaviour in blocks #1028

Closed
@ErisDS

Description

@ErisDS

I'm not sure if this is a bug or not, but it seems very unexpected:

At the top level of the context tree, assuming an object a bit like {a: 1, b: 2}

{{#if a}}
<p>Output: {{b}}</p>
{{/if}}   

It is expected that {{b}} would become 2.

However, when inside the scope of an object and using ../ path segments to reference the parent template, things get a bit weird if you also add a conditional into the mix:

Assume an object like {a: {b: true}, c: 'd'}

{{#a}}
    <p>Output: {{../c}}</p>
  {{#if b}}
    <p>Output: {{../c}}</p>
  {{/if}}
{{/a}}   

I would expect the two items above to both output the same... however in order to output c, it requires two ../ segments - which I don't understand :(

{{#a}}
  {{#if b}}
    <p>Output: {{../../c}}</p>
  {{/if}}
{{/a}}   

Did I find a bug or am I missing something?

Fiddle with the above examples in detail: http://jsfiddle.net/ErisDS/618njbng/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions