将模板变量作为Meteor Spacebars(或Handlebars)中自定义块助手的值传递

时间:2015-01-27 06:15:09

标签: meteor handlebars.js spacebars

通常如果我想传递模板变量,我可以使用' ../'而不是{{}}(如How to pass a template variable to a template helper function to preserve context?所示)。

但是,我试图传递模板变量作为将通过自定义块助手提供的值的一部分。

作为一个非常简单的例子,想象{{name}}已在下面的模板中定义,我希望将其作为标题传递:

  {{#Card title= ../name }}
    <div class="map-container">
      Neat name!
    </div>
  {{/Card}}

我的自定义块助手看起来像这样:

<template name="Card">
  <h1 class="card-title">{{title}}</h1>
  <div class="card-content">
    {{>Template.contentBlock}}
  </div>
</template>

0 个答案:

没有答案