Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rendering partials within a partials in middleman

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"

like image 457
Walrus the Cat Avatar asked Apr 20 '15 16:04

Walrus the Cat


1 Answers

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.

like image 166
chischaschos Avatar answered Oct 20 '22 23:10

chischaschos