How to rendering partials within a partials in middleman

柔情痞子 提交于 2019-12-10 13:06:29

问题


I have some Haml partials, many of which contain the boilerplate

.container .row .col-lg-12

When I try to abstract that out ala = partial "site_section", I get:

syntax error, unexpected keyword_end, expecting end-of-input end;end;end;end

I'm using ruby 2.2.2.

How do I render a Haml partial within a Haml partial in Middleman?

Thanks

update This is apparently some kind of special case dealing with my partial (above). I have other partials-within-partials rendering just fine.

update With respect to this this repo, the layout would actually be:

_site_section:

.container .row .col-lg-12

_nested_section:

= partial "site_section"
  MOAR (nested) HAML

index.haml:

=partial "nested_section"


回答1:


Because of the way HAML works the following is invalid:

= partial "site_section"
  MOAR (nested) HAML

If you want to add more text or HAML then you can achieve it for example by putting the text at the same level of the previous line

= partial "site_section"
MOAR (nested) HAML

Or nesting it within a div:

= partial "site_section"
.more   
  MOAR (nested) HAML

So If what you are trying to do is to nest extra HAML to the output of the site_section partial, then you have to put the nested extra HAML in the nested partial:

.container
  .row
    .col-lg-12
      = partial 'nested_stuff'
= partial 'nested_stuff'

Hope this helps, I updated the repo with the working example.



来源:https://stackoverflow.com/questions/29752830/how-to-rendering-partials-within-a-partials-in-middleman

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!