如何在中间人的部分中渲染部分

Wal*_*Cat 7 ruby haml templates partials middleman

我有一些Haml部分,其中许多包含样板

.container .row .col-lg-12

当我试图从ala中抽象出来时= partial "site_section",我得到:

syntax error, unexpected keyword_end, expecting end-of-input end;end;end;end
Run Code Online (Sandbox Code Playgroud)

我正在使用ruby 2.2.2.

如何在Middleman的Haml部分内渲染出Haml?

谢谢

更新 这显然是某种特殊情况处理我的部分(上图).我有其他部分内部部分渲染就好了.

更新 关于这个repo,布局实际上是:

_site_section:

.container .row .col-lg-12

_nested_section:

= partial "site_section"
  MOAR (nested) HAML
Run Code Online (Sandbox Code Playgroud)

index.haml:

=partial "nested_section"

chi*_*hos 1

由于 HAML 的工作方式,以下内容无效:

= partial "site_section"
  MOAR (nested) HAML
Run Code Online (Sandbox Code Playgroud)

如果您想添加更多文本或 HAML,则可以通过将文本放置在上一行的同一级别来实现

= partial "site_section"
MOAR (nested) HAML
Run Code Online (Sandbox Code Playgroud)

或者将其嵌套在 div 中:

= partial "site_section"
.more   
  MOAR (nested) HAML
Run Code Online (Sandbox Code Playgroud)

因此,如果您想要做的是将额外的 HAML 嵌套到site_section部分的输出中,那么您必须将嵌套的额外 HAML 放入嵌套部分中:

.container
  .row
    .col-lg-12
      = partial 'nested_stuff'
= partial 'nested_stuff'
Run Code Online (Sandbox Code Playgroud)

希望这有帮助,我用工作示例更新了存储库