我有一个像这样的文件夹结构:
- components/
- foo/
- index.js
- foo.handlebars
- foo.scss
- bar/
- index.js
- bar.handlebars
- bar.handlebars
Run Code Online (Sandbox Code Playgroud)
为了方便地解析组件部分,我提供了一个可以找到正确路径的助手,将其转换bar为components/bar/bar.handlebars. 这个助手叫做getPartialForTemplate.
在我的模板中,我这样做:
{{> (getPartialForTemplate 'foo') some=props}}
这很好,但是当我需要使用已解析的模板作为块时,我遇到了一个问题:
{{#> (getPartialForTemplate 'foo')}}
<p>Some text here..</p>
{{/WHATGOESHERE???}}
Run Code Online (Sandbox Code Playgroud)
这似乎是 Handlebars 中的一个语法缺陷,因为我希望它的语法特性能够协同工作。有没有办法做到这一点?
github上有一个未解决的问题,建议的解决方法是这样的:
{{#>( lookup . 'intendedTemplate' )}}
No template matched for "{{intendedTemplate}}"
{{/undefined}}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
740 次 |
| 最近记录: |