【问题标题】:Load handlebars js partial with different data用不同的数据加载车把js部分
【发布时间】:2016-05-17 19:49:47
【问题描述】:

有没有办法使用部分但在其中包含不同的数据?或者换句话说,我可以在另一个模板中包含一个模板把手模板吗?

基本上是这样的:

        <script id="countries-nav" type="text/x-handlebars-template">
            {{#each this}}
                <li class="item"><a href="#/countries/{{ISO}}">{{Country}}</a></li>
            {{/each}}
        </script>

    <script id="countryspecifics" type="text/x-handlebars-template">
        {{#each this}}
            <div class="country__title">
                <h2>{{title}}</h2>
            </div>
            {{> countries-nav}}
        {{/each}}
    </script>

【问题讨论】:

    标签: javascript handlebars.js


    【解决方案1】:

    这是 Blaze 的基本功能:

    <template name="countries-nav">
        {{#each this}}
           <li class="item"><a href="#/countries/{{ISO}}">{{Country}}</a</li>
        {{/each}}
    </template>
    
    <template name="countryspecifics">
        {{#each this}}
            <div class="country__title">
                <h2>{{title}}</h2>
            </div>
            {{> countries-nav}}
        {{/each}}
    </template>
    

    【讨论】:

    • 我实际上是在流星之外使用它。
    • 那我推荐使用ractivejs.org
    猜你喜欢
    • 2013-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多