-
Notifications
You must be signed in to change notification settings - Fork 62
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
How to pass data between different templates in the same layout #30
Comments
Don't pass data via FlowLayout. Get data from the template itself. For an example, if your data inside the collection, simply access the collection in both of your templates. |
The data is from an HTTP call to an external server. Because client side HTTP call has to be asynchronous, the data needs to be saved to a reactive variable and then the template re-renders itself. I'd like to only make one HTTP call and render both templates. Any way to achieve this? |
Save the HTTP request results in a Session variable. Use Session.get('results') in a helper in each template. |
Yes, this is one method. I just want to avoid using global session variable as much as possible. It would be good that the router can provide such a functionality. |
+1 This for example can be necessary to set a templates state from the route. So passing data should definitely be possible, even if it is not reactive. |
I have a page with two sections, header and main, each has its own template. Some fairly expensive reactive data is needed by both templates. If the visitor browse another page, the reactive data should be destroyed. Is it possible to attach that reactive data to the route/layout?
Without FlowLayout's support, it is possible to create a parent template that includes both header and main templates, and pass the data to them. That parent template is actually the layout template. It means we need to create a separate layout template when some data is different. Does that make sense?
Say, I have the following layout:
FlowLayout.render ('layout', {header : 'headerTemplate', main : 'mainTemplate'});
I need to pass some complicated object data between headerTemplate and mainTemplate. Does it mean I need to create a new "layout" template?
The text was updated successfully, but these errors were encountered: