-
-
Save dtjm/528642 to your computer and use it in GitHub Desktop.
Haml and Sass plugin for Jekyll 0.6.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ofStandardError
, sorescue
will miss it and probably lead to a frustrating debugging session; or, you could rescueException
, but that seems blunt. Of course, HAML might raise other errors you're catching withStandardError
.Also,
rescue
expectsStandardError
by default, sorescue => e
would be sufficient.