In Meteor, a Spacebar template could include another template.
<template name="slots"> {{> slot }} </template> <template name="slot"> <div class="slot"> <div class="number">100</div> </div> </template>
Sometime we want to reuse the template with different variables. Here is an example.
<template name="slots"> {{> slot one}} {{> slot two}} {{> slot three}} </template> <template name="slot"> <div class="slot"> <div class="number">{{number}}</div> </div> </template>
So what is one, two and three stands for? So they are defined in the client side.
client/js/main.js
Template.slots.one = { number: 1 } Template.slots.two = { number: 2 } Template.slots.three = { number: 3 }
We could even define multiples variables.
Template.slots.one = { number: 1, another_number: 100, ... }
Done =)
Reference: StackOverflow – Is there a way to pass variables into templates in Meteor?
Filed under: Meteor Tagged: Meteor, Spacebars