Skip to content

Commit 15f0383

Browse files
committed
Basic support for Haml layouts.
1 parent 072d9e7 commit 15f0383

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

README.textile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ To transform ".haml":http://github.com/nex3/haml/tree/master files to HTML
172172

173173
$ jekyll --haml
174174

175-
Note that files must have a YAML metadata block at the top to be converted,
176-
and that Haml cannot currently be used for layouts -- only posts and pages.
175+
Note that pages and posts must have a YAML metadata block at the top to be
176+
converted. Layouts don't need to.
177177

178178
Haml content is intentionally not filtered, so you can use any Ruby code.
179179

@@ -269,9 +269,8 @@ h2. Data
269269

270270
Jekyll traverses your site looking for files to process. Any files with YAML
271271
front matter (see below) are subject to processing. For each of these files,
272-
Jekyll makes a variety of data available to the pages via Haml (regular pages
273-
only) or the Liquid templating system. The following is a reference of the
274-
available data.
272+
Jekyll makes a variety of data available to the pages via Haml or the Liquid
273+
Liquid templating system. The following is a reference of the available data.
275274

276275
h3. Global
277276

lib/jekyll/convertible.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ def do_layout(payload, layouts)
8989
layout = layouts[self.data["layout"]]
9090
while layout
9191
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
92-
self.output = Liquid::Template.parse(layout.content).render(payload, info)
92+
93+
if site.config['haml'] && layout.content.is_a?(Haml::Engine)
94+
context = OpenStruct.new(
95+
:page => OpenStruct.new(payload["page"]),
96+
:site => OpenStruct.new(payload["site"]),
97+
:content => payload["content"])
98+
context.extend(HamlHelpers)
99+
self.output = layout.content.render(context)
100+
else
101+
self.output = Liquid::Template.parse(layout.content).render(payload, info)
102+
end
93103

94104
layout = layouts[layout.data["layout"]]
95105
end

lib/jekyll/layout.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def initialize(site, base, name)
2222

2323
self.process(name)
2424
self.read_yaml(base, name)
25+
self.transform
2526
end
2627

2728
# Extract information from the layout filename

0 commit comments

Comments
 (0)