Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
HAML plugin for jekyll
# _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
---
---
<!-- _layouts/home.haml -->
%html
%head
%title= page.title
%body
#container
#header HEADER
#content
= content
#footer FOOTER
---
layout: home
title: Home Page
---
%h1 Hello World?
@georgedrummond

This comment has been minimized.

Show comment Hide comment
@georgedrummond

georgedrummond Jun 2, 2011

will this work with github pages?

will this work with github pages?

@dtjm

This comment has been minimized.

Show comment Hide comment
@dtjm

dtjm Jun 2, 2011

I don't think so. There is an open ticket here: mojombo/jekyll#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.

Owner

dtjm commented Jun 2, 2011

I don't think so. There is an open ticket here: mojombo/jekyll#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.

@bcardarella

This comment has been minimized.

Show comment Hide comment
@bcardarella

bcardarella Jun 27, 2011

How are you pre-processing the HAML?

How are you pre-processing the HAML?

@georgedrummond

This comment has been minimized.

Show comment Hide comment
@georgedrummond

georgedrummond Jun 27, 2011

see line 24 onwards

see line 24 onwards

@dtjm

This comment has been minimized.

Show comment Hide comment
@dtjm

dtjm Jun 27, 2011

@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)

Owner

dtjm commented Jun 27, 2011

@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)

@joshuairl

This comment has been minimized.

Show comment Hide comment
@joshuairl

joshuairl Nov 4, 2013

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

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

@topher6345

This comment has been minimized.

Show comment Hide comment
@topher6345

topher6345 Jan 20, 2014

This plguin isn't converting my haml layouts to html

But it works for the content pages, any ideas?

This plguin isn't converting my haml layouts to html

But it works for the content pages, any ideas?

@jalcine

This comment has been minimized.

Show comment Hide comment
@jalcine

jalcine Aug 29, 2014

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

jalcine commented Aug 29, 2014

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

@2xG

This comment has been minimized.

Show comment Hide comment
@2xG

2xG Apr 29, 2015

I have an error with new version of haml gem.
http://blog.haml.info/post/42998475354/haml-4-0-has-been-released says that markup filters have been moved to separate gem 'haml-contrib'

2xG commented Apr 29, 2015

I have an error with new version of haml gem.
http://blog.haml.info/post/42998475354/haml-4-0-has-been-released says that markup filters have been moved to separate gem 'haml-contrib'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment