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

Passing a type boolean variable to an addHelper function causes errors #631

Open
1 task done
MarcGodard opened this issue Nov 18, 2018 · 4 comments
Open
1 task done

Comments

@MarcGodard
Copy link

How often can you reproduce it?

  • Always

Description:

Passing a variable of type boolean to an adHelper function causes errors.

Steps to reproduce:

Create a model with variable type boolean. Populate model. Create an addHelper function. Loop over model list while passing values to an addHelper (haven't tested without the loop).

{{#each(row)}}
     {{someHelper(booleanVariable)}}
{{/each}}

with

stache.addHelper('someHelper', (booleanVariable) => {
     if (booleanVariable) return 'true'
     else return 'false'
})

Error:

can-log.js:98 RangeError: Maximum call stack size exceeded
    at Object.hydrateAst (expression.js:1)
    at Object.hydrateAst (expression.js:315)
    at Object.hydrateAst (expression.js:263)
    at Object.hydrateAst (expression.js:315)
    at Object.hydrateAst (expression.js:263)
    at Object.hydrateAst (expression.js:315)
    at Object.hydrateAst (expression.js:263)
    at Object.hydrateAst (expression.js:315)
    at Object.hydrateAst (expression.js:263)
    at Object.hydrateAst (expression.js:315)

Expected results:

Should cast the type boolean and work :)

Actual results:

The error above.

Environment:

Software Version
can-stache version 5.16.5
Browser Chrome
Operating system Mac os
Node v8.12.0
@MarcGodard MarcGodard changed the title Passing a type boolean variable to an adHelper function causes errors Passing a type boolean variable to an addHelper function causes errors Nov 18, 2018
@chasenlehara
Copy link
Member

chasenlehara commented Nov 19, 2018

@MarcGodard Any chance you have a runnable code example or could make one (CodePen, etc.)?

@MarcGodard
Copy link
Author

@chasenlehara I have never made a codePen for canjs. You have an example? I am a donejs user.

@justinbmeyer
Copy link
Contributor

Much of the canjs site has been updated to run examples in codepen. I’d look here for a stache/component example you can start from: https://canjs.com/doc/guides/html.html

Can-stache’s docs also have codepens too

@chasenlehara
Copy link
Member

The Setting Up CanJS page also has a starter CodePen (click on the Edit on CodePen button in the top right of the embedded pen): https://canjs.com/doc/guides/setup.html#OnlineCodeEditors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants