车把动态局部挡路 [英] Handlebars Dynamic Partial Block
本文介绍了车把动态局部挡路的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的文件夹结构如下:
- components/
- foo/
- index.js
- foo.handlebars
- foo.scss
- bar/
- index.js
- bar.handlebars
- bar.handlebars
为了方便地解析组件部分,我提供了一个帮助器,它将找到正确的路径,将bar
转换为components/bar/bar.handlebars
。此帮助器称为getPartialForTemplate
。
在我的模板中,我做:
{{> (getPartialForTemplate 'foo') some=props}}
这很好,但是当我需要将解析的模板用作挡路时,我遇到了一个问题:
{{#> (getPartialForTemplate 'foo')}}
<p>Some text here..</p>
{{/WHATGOESHERE???}}
这似乎是Handlebar中的语法缺陷,因为我希望它的语法功能能够协同工作。有办法做到这一点吗?
推荐答案
GitHub上有一个open issue,建议的解决方法如下:
{{#>( lookup . 'intendedTemplate' )}}
No template matched for "{{intendedTemplate}}"
{{/undefined}}
这篇关于车把动态局部挡路的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文