Permalink
Browse files

Basic support for Haml layouts.

  • Loading branch information...
henrik committed Apr 16, 2009
1 parent 072d9e7 commit 15f03836df41b190c5ee05e47dab578e61e1cfde
Showing with 16 additions and 6 deletions.
  1. +4 −5 README.textile
  2. +11 −1 lib/jekyll/convertible.rb
  3. +1 −0 lib/jekyll/layout.rb
View
@@ -172,8 +172,8 @@ To transform ".haml":http://github.com/nex3/haml/tree/master files to HTML
$ jekyll --haml
-Note that files must have a YAML metadata block at the top to be converted,
-and that Haml cannot currently be used for layouts -- only posts and pages.
+Note that pages and posts must have a YAML metadata block at the top to be
+converted. Layouts don't need to.
Haml content is intentionally not filtered, so you can use any Ruby code.
@@ -269,9 +269,8 @@ h2. Data
Jekyll traverses your site looking for files to process. Any files with YAML
front matter (see below) are subject to processing. For each of these files,
-Jekyll makes a variety of data available to the pages via Haml (regular pages
-only) or the Liquid templating system. The following is a reference of the
-available data.
+Jekyll makes a variety of data available to the pages via Haml or the Liquid
+Liquid templating system. The following is a reference of the available data.
h3. Global
View
@@ -89,7 +89,17 @@ def do_layout(payload, layouts)
layout = layouts[self.data["layout"]]
while layout
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
- self.output = Liquid::Template.parse(layout.content).render(payload, info)
+
+ if site.config['haml'] && layout.content.is_a?(Haml::Engine)
+ context = OpenStruct.new(
+ :page => OpenStruct.new(payload["page"]),
+ :site => OpenStruct.new(payload["site"]),
+ :content => payload["content"])
+ context.extend(HamlHelpers)
+ self.output = layout.content.render(context)
+ else
+ self.output = Liquid::Template.parse(layout.content).render(payload, info)
+ end
layout = layouts[layout.data["layout"]]
end
View
@@ -22,6 +22,7 @@ def initialize(site, base, name)
self.process(name)
self.read_yaml(base, name)
+ self.transform
end
# Extract information from the layout filename

0 comments on commit 15f0383

Please sign in to comment.