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
whitecolor opened this Issue Nov 11, 2013 · 5 comments

Comments

Projects
None yet
3 participants
@whitecolor
Contributor

whitecolor 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

This comment has been minimized.

Show comment
Hide comment
@imjoshdean

imjoshdean Nov 11, 2013

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?

Contributor

imjoshdean commented Nov 11, 2013

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

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Nov 11, 2013

Contributor

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?

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?

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Nov 11, 2013

Contributor

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.

Contributor

whitecolor 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

This comment has been minimized.

Show comment
Hide comment
@imjoshdean

imjoshdean Nov 11, 2013

Contributor

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

Contributor

imjoshdean commented Nov 11, 2013

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

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Nov 11, 2013

Contributor

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

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

Merge pull request #541 from bitovi/538-helpers
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