Question

For example, I want to do something like this:

= render 'header_splash'
  #about.section
    h2 You've reached our home page.

... where header_splash.slim looks like this:

#header_splash
  h1 Here's the splash image and the nav elements

I want the #about section to be rendered inside the header_splash div but it's rendering outside of it, even though it's nested in the code.

Is it at all possible to nest like this?

Was it helpful?

Solution

You can't. If you want something rendered in a partial, you need to render it in the partial. You can pass in additional variables if necessary:

= render partial: 'header_splash', locals: { header_text: "you've reached ..." }

The locals hash will be available in your partial as variables:

h2= header_text
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top