Nested Template
Opened this issue · 4 comments
Hello,
I am working on a project and need to proper split the template based on function unit. To achieve that I would need to nest the template and would like to know the proper way in doing that.
I have a base layout template below
baseLayout.html
<template name="baseLayout">
{{> navigation}}
{{> notifications}}
{{> Template.dynamic template=Body}}
</template>
Both navigation and notifications don' t have anything special. While for the Body it need to further nest as:-
Body.html
<template name="Body">
{{> Template.dynamic template=SearchTemplate}}
{{> Template.dynamic template=ResponseTemplate}}
</template>
For the route, I only know how to pass the body dynamic template while is there a way I can pass the Search Template and ResponseTemplate?
Route.js
FlowRouter.route('/', {
name: 'baseLayout',
action: function(params, queryParams) {
BlazeLayout.render('baseLayout', {Body: "Body"});
})
It is different case. They are referring to a master template with more than one child template. I am referring to child template have child template.
There are no built in ways. But you can do like this.
- Think search template is also a kind of layout. Pass some data into that, which contains the nested layout names.
Try this:
FlowRouter.route('/', {
name: 'baseLayout',
action: function(params, queryParams) {
var options = {SearchTemplate: 'aa', ResponseTemplate: 'bb'};
BlazeLayout.render('baseLayout', {Body: "Body", options: options});
})
<template name="baseLayout">
{{> navigation}}
{{> notifications}}
{{> Template.dynamic template=Body data=options}}
</template>
I didn't check the code. But this should be working.
@frankcheong no, you are asking the same thing from #24, I also used master with 1 dynamic and nested with 2 dynamic. Just add
BlazeLayout.render('baseLayout', {
Body: "Body",
SearchTemplate: "**title**",
ResponseTemplate: "**title**"
});
Check the demo repository / demo app, it works great.