Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否支持block嵌套 #468

Closed
tangye1234 opened this issue Aug 27, 2017 · 4 comments
Closed

是否支持block嵌套 #468

tangye1234 opened this issue Aug 27, 2017 · 4 comments

Comments

@tangye1234
Copy link

tangye1234 commented Aug 27, 2017

参考Pug的案例

Things of note:

  • Overriding a block is optional. If you don't override a block, it will simply contain either the default content from the base template (if any is specified), or no content at all (if not).
    You can have an unlimited number of blocks with different names - for example, the one in our example is called content. You can decide to override any of them from a template, all of them, or none at all. It's up to you.
  • You can nest multiple blocks with different names. This can be useful for more complex layout variations.
  • You can have multiple levels of inheritance - any template you are inheriting from can itself inherit from another template. This can be especially useful in combination with nested blocks, for complex cases.

话说支持extend多级,同时要支持block嵌套是一个基本的模板渲染功能。

@tangye1234
Copy link
Author

如题,很多nodejs端,老牌的模板渲染器都支持 nested block,在稍微复杂的一点的场景下,为了复用,而不得不采用这种方式。

yinheli added a commit to yinheli/art-template that referenced this issue Oct 19, 2017
调整了 block 函数格式,多行输出
对嵌套 block (通过名称重复判断)分支处理
增加 嵌套 block 的例子
@tangye1234
Copy link
Author

#487 fixes this problem.

@aui
Copy link
Owner

aui commented Aug 21, 2018

已经发布

@aui aui closed this as completed Aug 21, 2018
@zhaiyuzhai
Copy link

好像还是不能嵌套:
layout.art:

{{block ‘block1’}}

{{block 'header1'}} {{/block}} {{block 'header2'}} {{/block}} {{block 'header3'}} {{/block}} {{block 'header4'}} {{/block}} {{block 'header5'}} {{/block}} {{/block}}

content.art:

{{block 'header1'}}

{{/block}} 这么写好像不管用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants