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

mustache: 'with' string is interpreted as with helper keyword #538

Closed
wclr opened this issue Nov 11, 2013 · 5 comments
Closed

mustache: 'with' string is interpreted as with helper keyword #538

wclr opened this issue Nov 11, 2013 · 5 comments
Labels
Milestone

Comments

@wclr
Copy link
Contributor

wclr commented Nov 11, 2013

can.view.mustache('{{text}}').render({text:'with'})

cases an error in mustache.js

Look at the console:
http://jsfiddle.net/xKc3H/253/

@ghost ghost assigned imjoshdean Nov 11, 2013
@imjoshdean
Copy link
Contributor

EDIT: Upon further investigation and testing with Handlebars, this is about par for the course. For example if you go to http://tryhandlebarsjs.com/ and try the following data:

{ "each" : "bar" }

with the following template:

<h1>{{each}}</h1>

it'll balk at you with the same type of error:

// TypeError: Cannot read property 'fn' of undefined

The real question is: For this type of situation do we maintain the status quo, or do we do something? If we do something, what is it that we do?

@daffl
Copy link
Contributor

daffl commented Nov 11, 2013

I don't think this is the same issue. In our case {{text}} is evaluated and then the value tried to run as a helper. Or is text also a helper?

@wclr
Copy link
Contributor Author

wclr commented Nov 11, 2013

Well "each" is a keyword should probably not be used as data attribute name.

In my case I don't use keyword as data attribute name. {{text}} is not a helper. Error appears only if {text: 'with'}. Strange bug.

@imjoshdean
Copy link
Contributor

True, but in our case with is also a keyword.

@daffl
Copy link
Contributor

daffl commented Nov 11, 2013

A string value in your view data should never be interpreted as a keyword for anything.

daffl added a commit that referenced this issue Nov 12, 2013
Fixes #538 helpers aren't called is data passed to the template happens ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants