我正在使用 handlebarsjs 创建一个 Ghost 模板。在 post.hbs 页面(博客文章视图)上,我正在寻找一种解决方案,以在 post.hbs 模板的底部包含具有相同标签的其他博客标题。(有点像在 Wordpress 网站上,您会在博客文章页面的底部看到类似的文章。)
这是我到目前为止所拥有的:
{{#foreach tags}}
{{#foreach posts}}
<p>{{{title}}}</p>
{{/foreach}}
{{/foreach}}
有没有办法设置变量和过滤条件?
var current-tag = tag.name
foreach(posts as post)
if(post.tag == current-tag)
<p>{{post.title}}</p>