例如,我想做这样的事情:
= render 'header_splash'
#about.section
h2 You've reached our home page.
... header_splash.slim
看起来像这样:
#header_splash
h1 Here's the splash image and the nav elements
我希望#about
部分在header_splash
div
内呈现,但它在其外部呈现,即使它嵌套在代码中。
是否可以像这样嵌套?
答案 0 :(得分:1)
你做不到。如果你想要在局部渲染的东西,你需要在局部渲染它。如有必要,您可以传入其他变量:
= render partial: 'header_splash', locals: { header_text: "you've reached ..." }
locals
哈希将在您的部分变量中可用:
h2= header_text