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

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

Closed
roblillack opened this issue Jun 7, 2021 · 0 comments · Fixed by #54
Closed

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

roblillack opened this issue Jun 7, 2021 · 0 comments · Fixed by #54

Comments

@roblillack
Copy link

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. 😭
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

Successfully merging a pull request may close this issue.

1 participant