0
レンダリング時にハンドルバーテンプレートに変数を渡す方法はありますか?私は、このテンプレートがあります。テンプレートをレンダリングするときにハンドルバーに変数を渡す
<script id="listingTopics" type="text/x-handlebars-template">
{{#each this}}
<div class="wrapper_individual_listing_topic wrapper_form_dark">
<div class=" form_section">
<div class="topics_titles wrapper_listing_topics">
<a href="topic-{{id}}" class="listing-topics">{{title}}</a> <svg class="affinity {{heartClass}}" data-topicid="{{id}}"><use xlink:href="#starEmpty"/></svg>
</div>
<div class="topic-description hide topic-{{id}}">
<p class="text_standard">{{body}}</p>
</div>
</div>
</div>
{{/each}}</script>
をそして私は、私はテンプレートをレンダリングするときに設定したい変数がこれを行うには、私の最初のアイデアは、機能を設定することでした
heartclassです:
function showTopics(container, data, heartclass) {
var heartClass = heartclass
var listingTopicsCompiled = listingTopicsTemplate(data);
$(container).append(listingTopicsCompiled);
}
このような関数を呼び出してください。
showTopics('#listing-topics', not_favorite_exchanges, 'unfav');
これをどのように攻撃するかわかりません。どんな助けでも大歓迎です!