2

我有一个看起来像这样的布局:

body
    header.l-header.l-site-width
        block header

    // include the block with the name body form whatever file that uses layout
    .l-body.l-site-width   
        block body

    footer.l-footer.l-site-width
        block footer

现在我没有在使用布局的文件中指定标题块,我想使用默认包含。

我试过了:

block header || "something else"

在最好的情况下:

block header || include ../partials/base/header

它不起作用,但不会引发错误。知道怎么做吗?

4

1 回答 1

6

您实际上可以在标题块中编写默认代码。

block header
  include ../partials/base/header

block如果你现在扩展你的布局,你可以用一个简单的独立语句覆盖块的内容。

extends layout

block header
  ... your code ...

或者,您可以使用appendprepend添加到块中,在这种情况下,旧内容仍然存在。

于 2013-08-08T08:02:39.937 回答