Skip to content

Instantly share code, notes, and snippets.

@radamant
Created July 19, 2010 14:16
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save radamant/481456 to your computer and use it in GitHub Desktop.
Save radamant/481456 to your computer and use it in GitHub Desktop.
Simple haml-sass conversion for jekyll
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)
engine = Haml::Engine.new(content)
engine.render
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)
engine = Sass::Engine.new(content)
engine.render
end
end
end
@mwotton
Copy link

mwotton commented May 22, 2011

sorry if this is obvious/stupid - how do you use the stuff defined in the YAML front-matter inside the haml chunk?

i could always move it down as a variable, but that's a bit ugly...

@dtjm
Copy link

dtjm commented May 22, 2011

@mwotton, you have to put it inside Moustache markup. See the docs here: https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter

@mwotton
Copy link

mwotton commented May 22, 2011

@dtjm so no variables are actually defined for the use of the Haml renderer? Does the Moustache get run first or second? I guess " - @InputData = {{ inputdata }}" isn't terrible, if the Moustach gets run first...

@dtjm
Copy link

dtjm commented May 23, 2011

@mwotton, oh I see what you are saying. I don't know if there are variables available in the HAML scope.

@rubyonrailstutor
Copy link

is it possible to mix haml and markdown ? or is that a crazy question because both are a kind of templating sugar and why would one be used with the other ?

@samurailink3
Copy link

@rubyonrailstutor Absolutely! Check out this section of the HAML docs. It requires the markdown to be put in it's own section, but it should work nicely from what others on the net have said.

Copy link

ghost commented Aug 22, 2014

@radamant how can I prevent Jekyll completely from compiling my SCSS files? I want to handle it myself with 3rd party solutions outside of Jekyll.

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