【发布时间】:2011-02-27 01:12:50
【问题描述】:
我正在单独使用 Haml (Haml/Sass 3.0.9 - Classy Cassidy) 来生成静态 HTML。我想创建一个所有其他模板都继承的共享布局模板。
Layout.haml
%html
%head
%title Test Template
%body
.Content
Content.haml
SOMEHOW INHERIT Layout.haml
SOMEHOW Change the title of the page "My Content".
%p This is my content
生产:
Content.html
<html>
<head>
<title>My Content</title>
</head>
<body>
<div class="Content">
<p>This is my content</p>
</div>
</body>
</html>
但这似乎不可能。我已经看到在将 Haml 与 Rails 一起使用时使用渲染部分,但在单独使用 Haml 时找不到任何解决方案。
必须将布局代码放入我的所有模板中将是维护的噩梦;所以我的问题是如何避免这样做?有没有解决这个问题的标准方法?我错过了一些基本的东西吗?
我发现了一个类似的问题:Rendering HAML partials from within HAMLoutside of Rails
【问题讨论】: