0
我有一个模板助手返回一个会议的价值,在这种情况下它返回的人数1:流星使用Spacebars逻辑不服从逻辑
Template.Student.helpers({
curWeek: function() {
return Session.get('CurrentWeek').substr(0, 1);
},
我的模板有一个表,我试图根据辅助函数的值将表中的一部分打印到表中。所以我在模板中有一些逻辑来打印正确的部分。但它不服从逻辑。即使curWeek的值返回值1,模板也会在{{#if curWeek 2}}下运行逻辑,所以两者都在表中。我只希望{{#if curWeek 1}}下的部分运行,因为这就是值。我没有正确使用逻辑?
<template name="Student">
{{#modalizeBody}}
<table class="bordered narrow">
<thead>
<tr>
<th>Name</th>
<th>Shift</th>
<th>Age</th>
<th>Sex</th>
<th>Level</th>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
</thead>
<tbody>
{{#each StudsWk1Master}}
{{#if curWeek 1}}
<tr>
<td>{{FullName}}</td>
<td>{{RoomWk1}}</td>
<td>{{calculateAge Bdate}}</td>
<td>{{Sex}}</td>
<td>{{Level}}</td>
<td>{{formatName this.Teachers.Week1.Sunday}}</td>
<td>{{formatName this.Teachers.Week1.Monday}}</td>
<td>{{formatName this.Teachers.Week1.Tuesday}}</td>
<td>{{formatName this.Teachers.Week1.Wednesday}}</td>
<td>{{formatName this.Teachers.Week1.Thursday}}</td>
<td>{{formatName this.Teachers.Week1.Friday}}</td>
<td>{{formatName this.Teachers.Week1.Saturday}}</td>
</tr>
{{/if}}
{{/each}}
{{#each StudsWk1Master}}
{{#if curWeek 2}}
<tr>
<td>{{FullName}}</td>
<td>{{RoomWk2}}</td>
<td>{{calculateAge Bdate}}</td>
<td>{{Sex}}</td>
<td>{{Level}}</td>
<td>{{formatName this.Teachers.Week2.Sunday}}</td>
<td>{{formatName this.Teachers.Week2.Monday}}</td>
<td>{{formatName this.Teachers.Week2.Tuesday}}</td>
<td>{{formatName this.Teachers.Week2.Wednesday}}</td>
<td>{{formatName this.Teachers.Week2.Thursday}}</td>
<td>{{formatName this.Teachers.Week2.Friday}}</td>
<td>{{formatName this.Teachers.Week2.Saturday}}</td>
</tr>
{{/if}}
{{/each}}
</tbody>
</table>
{{/modalizeBody}}
</template>
嗯,是的。弗洛伊德先生再次帮我解救!谢谢你,先生。 –