【问题标题】:EmberJs: How to render a template using its "data-template-name"EmberJs:如何使用其“数据模板名称”呈现模板
【发布时间】:2013-02-11 22:15:47
【问题描述】:

我有一个模板文件,它只生成一些 html(所以没有 App.ListView)。例如假设我有一个定义如下的“列表”:

<script type="text/x-handlebars" data-template-name="list"> 
    <div class="list">
    </div>
</script>

现在的问题是如何在另一个模板中定位这个模板

{{view "list" contextBinding="this"}}

这是jsfiddle

有什么建议吗?

干杯

【问题讨论】:

    标签: templates ember.js nested


    【解决方案1】:

    您可以使用{{template}}

    jsFiddle example

    <script type="text/x-handlebars" data-template-name="application">
        {{template list}}
    </script>
    

    有关各种帮助程序的细分,请参阅相关答案:Different rendering techniques in emberjs handlebars template

    【讨论】:

    • 另一件事。在一种情况下,我将视图的名称存储在变量中,您如何呈现这样的视图?例如:{{view config.viewName}} where config.viewName = "App.PeopleView"
    • 我认为最好在新线程中继续我的最后一个问题here
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-18
    • 2014-04-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多