Skip to content

Instantly share code, notes, and snippets.

@tamouse
Forked from dtjm/haml_converter.rb
Created October 4, 2013 01:31
Show Gist options
  • Select an option

  • Save tamouse/6819709 to your computer and use it in GitHub Desktop.

Select an option

Save tamouse/6819709 to your computer and use it in GitHub Desktop.

Revisions

  1. dtjm revised this gist Aug 10, 2010. 2 changed files with 3 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions haml_converter.rb
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # _plugins/haml_converter.rb

    module Jekyll
    class HamlConverter < Converter
    safe true
    1 change: 1 addition & 0 deletions layout/home.haml → home.haml
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    ---
    ---
    <!-- _layouts/home.haml -->
    %html
    %head
    %title= page.title
  2. dtjm created this gist Aug 10, 2010.
    28 changes: 28 additions & 0 deletions haml_converter.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    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
    5 changes: 5 additions & 0 deletions index.haml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    ---
    layout: home
    title: Home Page
    ---
    %h1 Hello World?
    11 changes: 11 additions & 0 deletions layout/home.haml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    ---
    ---
    %html
    %head
    %title= page.title
    %body
    #container
    #header HEADER
    #content
    = content
    #footer FOOTER