Skip to content

Context stacks seem to be walked the wrong direction for bool sections #53

@roblillack

Description

@roblillack

Hi @cbroglie 👋

variable name resolution in bool sections that are inside list sections seems to be broken: variables are resolved in the outer context first, before checking the inner one.

Let's take a look at this minimal example that can be added to the testcases in mustache_test.go and will make it fail immediately:

{`{{#section}}{{#bool}}{{x}}{{/bool}}{{/section}}`,
map[string]interface{}{
	"x": "broken",
	"section": []map[string]interface{}{
		{"x": "working", "bool": true},
	},
}, "working", nil},

So, the code is:

  1. happily iterating section section -> cool 👍
  2. diving into the bool section because that's true -> cool 👍
  3. trying to resolve x, but starts at the bottom of the stack (ie. the outer context) and finds “broken” there -> not cool. 😭

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions