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

Cannot call function csrfField #17

Closed
dimensi opened this issue Dec 23, 2017 · 4 comments
Closed

Cannot call function csrfField #17

dimensi opened this issue Dec 23, 2017 · 4 comments

Comments

@dimensi
Copy link

dimensi commented Dec 23, 2017

partials/popups.edge

@!component('components/modalLogin')

components/modalLogin

<form>
{{ csrfField() }}
</form>

Error

[1] { Error: Cannot call function csrfField from components/modalLogin.edge view
[1]     at Context.callFn (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Context/index.js:286:13)
[1]     at Template.templateFn (eval at run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:51:20), <anonymous>:9:52)
[1]     at Template.eval (eval at run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:51:20), <anonymous>:29:14)
[1]     at TemplateRunner.run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:54:39)
[1]     at Template.renderWithContext (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/index.js:445:55)
[1]     at Template.isolate.bind.newContext.$slot.main (eval at run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:51:20), <anonymous>:51:20)
[1]     at Template.isolate (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/index.js:398:5)
[1]     at Template.templateFn (eval at run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:51:20), <anonymous>:50:8)
[1]     at Template.eval (eval at run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:51:20), <anonymous>:81:14)
[1]     at TemplateRunner.run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:54:39)
[1]     at Template.runTimeRender (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/index.js:374:65)
[1]     at Template.templateFn (eval at run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:51:20), <anonymous>:4:18)
[1]     at Template.eval (eval at run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:51:20), <anonymous>:12:14)
[1]     at TemplateRunner.run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:54:39)
[1]     at Template.runTimeRender (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/index.js:374:65)
[1]     at Template.templateFn (eval at run (/home/dimensi/projects/paraspace/node_modules/edge.js/src/Template/Runner.js:51:20), <anonymous>:24:18) status: 500 }
@thetutlage
Copy link
Member

Components state is isolated, so you will have to pass the csrfField method to it from your parent template

@!component(‘name’, csrfField = csrfField)

@RomainLanz
Copy link
Member

Hey @edDimensi! 👋

According to the name of your component if think you should use partials instead of a component.

Components are created to be reused (like, Button, Modal, MenuItem, ...) and a state + slots are sent to them to change how they behave.

@dimensi
Copy link
Author

dimensi commented Dec 24, 2017

Hm, but i see issue #2 and csrfField it's global helper, not?

@thetutlage
Copy link
Member

It's a local variable share for each request, since the value of csrfField has to be different for each HTTP request.

@dimensi dimensi closed this as completed Dec 24, 2017
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

No branches or pull requests

3 participants