这是我的基本 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]
= 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
使用它会给我“语法错误,意外';'”。
基本上,我的问题是,如何yield
在一个 Slim 文件中有两个 s?像这样:
.span2.sidebar
< yield the sidebar here >
.span10
< yield other content here >