Meteor - Blaze easy-search 模板 - 如何将输入字段属性插入模板?

Meteor - Blaze easy-search template - how to insert input field attributes into template?

所以我有一个易于搜索的模板:

<template name="searchBox">

    <div class="">
        {{> EasySearch.Autosuggest index=PlayersIndex }}
    </div>

</template>

我想让输入字段看起来像这样(具有以下属性):

          <input
            type="text"
            placeholder="Type to add new player"
            ref="textInput"
          />

我试过将属性添加到参数中,但这似乎不起作用:

        {{> EasySearch.Autosuggest index=PlayersIndex type="text"}}

有什么实现方法吗?

只需在 HTML 中添加 attributes 属性:

{{> EasySearch.Input index=index attributes=inputAttributes}}

然后在您的 JS 中,用您需要的数据填充它:

`Template.leaderboard.helpers({
    inputAttributes: function () {
        return { 'class': 'easy-search-input', 'placeholder': 'Start searching...' };
    }
)}
`

我通过查看此 repo 找到了答案,因此请务必检查 github 存储库,因为它们可能包含有用的示例。 ;)