Jakob Alexander Eichler
Jakob Alexander Eichler

Reputation: 3056

Subparts for templates with Meteor & Blaze

Hello I am using Meteor & Blaze.

My routes look like this:

FlowRouter.route('/software', {
    name: 'software',
    action(params, queryParams)
    {
        BlazeLayout.render('App_body', {main_content: 'software_page'});
    }
});

And in App_body I use main_content (which holds the name of a template) like this:

{{> Template.dynamic template=main_content}}

But now I realized that I like to insert in App_body more than just "main_content". Is there a way to define subparts for each template, and refer to them, as this would represent my logical connection, which I have.

Upvotes: 0

Views: 33

Answers (1)

Michel Floyd
Michel Floyd

Reputation: 20227

There's an example at the top of the blaze-layout readme that uses dynamic templates:

html:

<template name="layout1">
  {{> Template.dynamic template=top}}
  {{> Template.dynamic template=main}}
</template>

<template name="header">
  <h1>This is the header</h1>
</template>

<template name="postList">
  <h2>This is the postList area.</h2>
</template>

<template name="singlePost">
  <h2>This is the singlePost area.</h2>
</template>

Now you can render the layout while feeding in multiple template names in the second parameter which is an object where each key specifies a template name.

js:

BlazeLayout.render('layout1', { top: "header", main: "postList" });

Upvotes: 1

Related Questions