Dynamic templates or something different?

Hi,

bear with me, I’m a newbie in Meteor. I have a page with 3 menus, each menu is showing a different content. However, this content has a UI part which is kind of common, basically a header. The only difference is a h1 tag in this header, which changes for each menu. At the moment I have 3 different templates for each content, but the header is duplicated, except the h1 tag… How should I reuse the code and also be able to populate the h1 tag correctly?

Ok, probably the normal solution would be to do something like this…

{{> ContentHeader header_title=“Clients” header_description=“Clients Management”}}

Yes - and within your ContentHeader template you would do something like:

<h1>{{title}}</h1>
{{description}}

And use template helpers to return these fields:

Template.ContentHeader.helpers({
  title: function() {
    return Template.instance().data.header_title;
  },
  description: function() {
    return Template.instance().data.header_description;
  }
});
1 Like