rubyhamloctopress

Where can I use HAML in Octopress?


So, according to the Octopress official page, it has HAML integration plugin. Naturally, I gave it a try. I backed up my source/_includes/custom/head.html file, converted it to haml and saved it as source/_includes/custom/head.haml. It gave me an error.

I tried doing the same with source/_layouts/page.html file, and it worked like a charm.

My question is, where can I and where can I not use HAML in an Octopress blog?


Solution

  • AS you can see from the source code, the HAML is only processing pages content.

    See the convert && output_ext methods.

    https://github.com/imathis/octopress/blob/master/plugins/haml.rb

    module Jekyll
      require 'haml'
      class HamlConverter < Converter
        safe true
        priority :low
    
        def matches(ext)
          ext =~ /haml/i
        end
    
        def output_ext(ext)
          ".html"
        end
    
        def convert(content)
          begin
            engine = Haml::Engine.new(content)
            engine.render
          rescue StandardError => e
              puts "!!! HAML Error: " + e.message
          end
        end
      end
    end