Answer the question
In order to leave comments, you need to log in
Change template state variable from outside?
Good
afternoon According to the manual, using the if block in the Spacebars template in Meteor I go as follows:
HTML side:
<div class="left-panel">
{{#if reconnaissance.state}}
{{#each cards}}
{{name}}
{{/each}}
{{/if}}
</div>
Template.Battlefield.helpers({
name1 : function()
{
return battles.findOne().name1;
},
name2 : function()
{
return battles.findOne().name2;
},
cards:function()
{
if (Meteor.user().username==battles.findOne().name1)
{
return BS.deck1;
}
else if (Meteor.user().username==battles.findOne().name2)
{
return BS.deck2;
}
else {
alert ("You name doesn't consist in battlestate");
}
},
reconnaissance:
{
state:true
}
});
Answer the question
In order to leave comments, you need to log in
Template.Battlefield.helpers.reconnaissance
can be made into a function, for example:
Template.Battlefield.helpers({
reconnaissance: function() {
var randomBoolean = Math.random() < 0.5;
return {
state: randomBoolean
}
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question