【发布时间】:2012-04-13 09:48:59
【问题描述】:
我基本上是在使用 Middleman 2,但如果只能在 Middleman 3 中完成,我可以切换到它
我有layout.haml 拥有所有样板文件,同时也是索引的布局。
现在我想要适用于其余页面的inner.haml 布局,将从layout.haml继承(我不会重复样板部分),将包括一些额外的常用样式/脚本,一些常用标记,然后将重新放置 yield 块。
目前我完全没有意识到我应该从哪里开始。我了解如何将inner.haml 设置为默认布局并将layout.haml 设置为“/”路由的布局,但是系统如何知道inner.haml 实际上嵌套在layout.haml 中?
示例设置
layout.haml
!!!5
%html
%head
%script(src="HTML5 shiv")
%title
My Site
\|
= yield_content :title
= stylesheet_link_tag "site.css"
= yield_content :page_styles
%body
%div(role="main")
= yield_content :content
%script(src="jquery")
= yield_content :page_scripts
index.html.haml
- content_for :title do
Index
- content_for :page_styles do
= stylesheet_link_tag "index.css"
- content_for :page_scripts do
%script(src="index.js")
- content_for :content do
Cool banner here
inner.haml
-# somehow inherits from / extends layout.haml
- content_for :page_styles do
-# somehow I'm putting some common content and then reinclude the block from the specific page
= stylesheet_link_tag "inner.css"
= yield_content :page_styles
-# same thing for page_scripts
- content_fir :content do
-# again I define some common HTML, then include page's content
【问题讨论】: