Skip to content

Commit

Permalink
Basic support for Haml layouts.
Browse files Browse the repository at this point in the history
  • Loading branch information
henrik committed Apr 16, 2009
1 parent 072d9e7 commit 15f0383
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 4 additions & 5 deletions README.textile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ To transform ".haml":http://github.com/nex3/haml/tree/master files to HTML


$ jekyll --haml $ jekyll --haml


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


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


Expand Down Expand Up @@ -269,9 +269,8 @@ h2. Data


Jekyll traverses your site looking for files to process. Any files with YAML 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, 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 Jekyll makes a variety of data available to the pages via Haml or the Liquid
only) or the Liquid templating system. The following is a reference of the Liquid templating system. The following is a reference of the available data.
available data.


h3. Global h3. Global


Expand Down
12 changes: 11 additions & 1 deletion lib/jekyll/convertible.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,7 +89,17 @@ def do_layout(payload, layouts)
layout = layouts[self.data["layout"]] layout = layouts[self.data["layout"]]
while layout while layout
payload = payload.deep_merge({"content" => self.output, "page" => layout.data}) 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"]] layout = layouts[layout.data["layout"]]
end end
Expand Down
1 change: 1 addition & 0 deletions lib/jekyll/layout.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def initialize(site, base, name)


self.process(name) self.process(name)
self.read_yaml(base, name) self.read_yaml(base, name)
self.transform
end end


# Extract information from the layout filename # Extract information from the layout filename
Expand Down

0 comments on commit 15f0383

Please sign in to comment.