HandlebarsJS动态部分认为变量未定义

时间:2019-06-17 13:59:00

标签: javascript handlebars.js

我有以下车把模板:

<ul class="glide__slides">
    {{#each items as |item| }}
        {{#with ../itemTemplate as |template|}}
            <li class="glide__slide temp-{{ template }}">
                {{> '../product-tile/product-tile' item }}
            </li>
        {{/with}}
    {{/each}}
</ul>

我希望将产品图块的部分导入更改为动态,而不是硬编码。

with块中的template的值为../product-tile/product-tile,与我当前要包含的部分完全相同。

根据HandlebarsJS Dynamic Partials Docs,我应该可以将部分包含更改为以下内容:{{> (lookup . 'template') }}

这不起作用,并且我在控制台中收到一条错误消息:The partial undefined could not be found

我在做什么错了?

0 个答案:

没有答案