在我的流星应用程序中,我有一个数据收集表单模板,如下所示:
<template name="IntroductionWizard_Step_1">
{{#with contributor}}
<div class="container">
<div class="hero-unit">
<h3 class="panel-title">Introduction Wizard Step 1: </h3>
<form class="form-vertical" role="form">
<label for="name" class="control-label"><h5 class="text-muted">Name</h5></label>
<input type="text" id="name" name="name" class="form-control-element" value="{{contributorName}}" placeholder="Name">
<label for="email" class="control-label">Email</label>
<input type="text" id="email" name="email" class="form-control-element" value="{{contributorEmail}}" placeholder="Email">
<label for="phone" class="control-label">Phone</label>
<input type="text" id="phone" name="phone" class="form-control-element" value="{{contributorPhone}}" placeholder="phone #">
<label for="orgRole" class="control-label">Org Role</label>
<input type="text" id="orgRole" name="orgRole" class="form-control-element" value="{{contributorOrgRole}}" placeholder="Org Role">
</form>
</div>
</div>
{{/with}}
</template>
这个模板的助手看起来像这样:
Template["IntroductionWizard_Step_1"].helpers({
contributor: function(n) {
return ContributorCollection.findOne({contributorName: "Jim Szczygiel"});
}
});
如果找到数据,则此帮助程序可以返回数据,或者不返回数据。目前,当返回数据时,它显示在这个表单中,但是,当没有返回数据时,这个页面显示为空 - 表单模板根本没有显示。即使没有返回数据,我应该怎么做才能仍然显示空模板表单?