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

Fix stack propagation bug in sections #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Arjav-Patel
Copy link

Consider the following mustache template:

Template = <<"
{{# list }}
{{# util.titlecase }}
{{# util.to_lower }}
{{ . }}
{{/ util.to_lower }}
{{/ util.titlecase }}
{{/ list }}
">>.

With the following data:

Data = #{
     "list" => ["ELEM 1", "ELEM 2", "ELEM 3"],
     "util" => #{
            "to_lower" => fun(Text, Render) -> string:to_lower(binary_to_list(Render(Text))) end,
             "titlecase" => fun(Text, Render) -> string:titlecase(binary_to_list(Render(Text))) end
      }
}.

If we run:

bbmustache:render(Template, Data).

We expect the following output:

Elem 1
Elem 2
Elem 3

But instead, we see the following:

This is because the stack context is not properly propagated when bbmustache iterates through lists.

Here is a JS fiddle that shows this working properly in mustache.js.

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 this pull request may close these issues.

1 participant