I’d like to write my layout files in haml, but it seems like jekyll treats layout files differently than pages and posts. I haven’t found anything about it in here, but perhaps it was a question that was answered and then nuked in the data loss.
I’ve kludged together the solution in the past, but since upgrading to 3.4, the kludge no longer works. Before digging in, I wanted to consult the community to see if there’s anything out there already.
Update: The third code snippet now contains a monkeypatch which allows layouts to compile.
I’m using a really simple haml converter plugin:
module Jekyll class HamlConverter < Converter safe true def setup return if @setup require 'haml' @setup = true rescue STDERR.puts 'do `gem install haml`' raise FatalException.new('Missing dependency: haml') end def matches(ext) ext =~ /haml/i end def output_ext(ext) '.html' end def convert(content) setup engine = Haml::Engine.new(content) engine.render end end end
In the past (v3.1ish) I was able to use something like this monkeypatch to make layouts renderable:
module Jekyll class Layout alias plain_init initialize def initialize *args plain_init *args self.content = transform end end end
Update, this modified monkeypatch is what’s needed to get Layouts to compile or render under 3.4.0:
module Jekyll class Layout alias plain_init initialize def initialize *args plain_init *args self.content = _renderer.convert content end def extname @ext end end end