Skip to content

@dtjm /haml_converter.rb forked from radamant/haml_converter.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Haml and Sass plugin for Jekyll 0.6.2
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
require 'sass'
class SassConverter < Converter
safe true
priority :low
def matches(ext)
ext =~ /sass/i
end
def output_ext(ext)
".css"
end
def convert(content)
begin
engine = Sass::Engine.new(content)
engine.render
rescue StandardError => e
puts "!!! SASS Error: " + e.message
end
end
end
end
@richardkmichael

Today I was bit by a Jekyll / HAML problem using a similar converter, so just a comment..

HAML raises SyntaxError on parse problems. In Ruby 1.9, SyntaxError is not a child of StandardError, so rescue will miss it and probably lead to a frustrating debugging session; or, you could rescue Exception, but that seems blunt. Of course, HAML might raise other errors you're catching with StandardError.

Also, rescue expects StandardError by default, so rescue => e would be sufficient.

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.