Ruby on rails 如何在一个Slim文件中包含多个`yield`s/`content_`s?
这是我的基本Slim文件:Ruby on rails 如何在一个Slim文件中包含多个`yield`s/`content_`s?,ruby-on-rails,ruby-on-rails-3,slim-lang,Ruby On Rails,Ruby On Rails 3,Slim Lang,这是我的基本Slim文件: doctype html html lang="en" head meta charset="utf-8" title= "#{yield(:title) || 'Home'} | #{app_config.app_name} " = csrf_meta_tags /! Le HTML5 shim, for IE6-8 support of HTML elements /[if lt IE 9] = javas
doctype html
html lang="en"
head
meta charset="utf-8"
title= "#{yield(:title) || 'Home'} | #{app_config.app_name} "
= csrf_meta_tags
/! Le HTML5 shim, for IE6-8 support of HTML elements
/[if lt IE 9]
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
/! Le styles
= stylesheet_link_tag :application
css:
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
body
= render "layouts/navigation"
.container-fluid
= render "layouts/messages"
- if show_title?
h1= yield(:title)
br
.span2.sidebar
- content_for :sidebar
.span10
= yield
.container
footer
hr
p Made by Awesoham with Rails and win.
= javascript_include_tag :application
这是特定控制器的特定Slim文件:
- title "All Known NEOs"
- unless @neos.empty?
table
- for neo in @neos
tr
td.name = neo.name
td.ra = neo.ra_str
td.dec = neo.dec_str
- content_for :sidebar do \
| test
使用它会给我“语法错误,意外的“;”
基本上,我的问题是,如何在一个Slim文件中有两个yield
s?
像这样:
.span2.sidebar
< yield the sidebar here >
.span10
< yield other content here >
.span2.sidebar
.span10
您可以在一个模板中获得多个收益率。你的问题可能是由其他原因引起的。