Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

HAML plugin for jekyll

View haml_converter.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
# _plugins/haml_converter.rb
 
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
View haml_converter.rb
1 2 3 4 5 6 7 8 9 10 11 12
---
---
<!-- _layouts/home.haml -->
%html
%head
%title= page.title
%body
#container
#header HEADER
#content
= content
#footer FOOTER
View haml_converter.rb
1 2 3 4 5
---
layout: home
title: Home Page
---
%h1 Hello World?

will this work with github pages?

Owner
dtjm commented

I don't think so. There is an open ticket here: https://github.com/mojombo/jekyll/issues/53

For now, you'll have to pre-process your Haml before sending it to Github pages. This is not too bad if you can set up your development environment to automatically compile the HAML whenever you save.

How are you pre-processing the HAML?

see line 24 onwards

Owner
dtjm commented

@bcardarella Since haml doesn't have a --watch option like SASS, you could use also try using the unix watch command. Maybe something like this: watch haml *.haml (Sorry I haven't tried it and I don't have any of my code in front of me right now)

Does home.haml actually work? I can't seem to get my layout to generate correctly with haml?

This plguin isn't converting my haml layouts to html

But it works for the content pages, any ideas?

@topher6345 what's the suffix of your layout files? Might wanna make them .html to make the plugin pick them up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.