如何实现Handlebar条件头

时间:2014-03-27 07:27:40

标签: javascript conditional handlebars.js frontend

布局( default.hbs ):

{{> header}}

{{> body}}

{{> footer}}

Header.hbs
容器带导航的标题

成就:
我不想在搜索页面中显示导航

请让我知道如何实现条件标题,我可以在所有页面中显示正常标题,而不在我的搜索页面中导航。

1 个答案:

答案 0 :(得分:1)

您需要传入一个变量来将该页面标识为搜索页面,然后在条件语句中使用该变量来呈现标题。有点像这样:

{{#unless isSearchPage}}
    {{> header}}
{{/unless}}

{{> body}}

{{> footer}}