Created
May 24, 2011 06:08
-
-
Save adamjspooner/988201 to your computer and use it in GitHub Desktop.
A Jekyll plugin to convert .styl to .css.
This file contains hidden or 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
stylus: | |
compress: true | |
path: ./path/to/styl |
This file contains hidden or 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
--- | |
--- | |
// See individual.styl below. Notice it has no YAML front matter. | |
@import 'individual' | |
This file contains hidden or 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
html | |
margin 0 | |
padding 0 |
This file contains hidden or 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
# A Jekyll plugin to convert .styl to .css | |
# This plugin requires the stylus gem, do: | |
# $ [sudo] gem install stylus | |
# See _config.yml above for configuration options. | |
# Caveats: | |
# 1. Files intended for conversion must have empty YAML front matter a the top. | |
# See all.styl above. | |
# 2. You can not @import .styl files intended to be converted. | |
# See all.styl and individual.styl above. | |
module Jekyll | |
class StylusConverter < Converter | |
safe true | |
def setup | |
return if @setup | |
require 'stylus' | |
Stylus.compress = @config['stylus']['compress'] if | |
@config['stylus']['compress'] | |
Stylus.paths << @config['stylus']['path'] if @config['stylus']['path'] | |
@setup = true | |
rescue LoadError | |
STDERR.puts 'You are missing a library required for Stylus. Please run:' | |
STDERR.puts ' $ [sudo] gem install stylus' | |
raise FatalException.new('Missing dependency: stylus') | |
end | |
def matches(ext) | |
ext =~ /styl/i | |
end | |
def output_ext(ext) | |
'.css' | |
end | |
def convert(content) | |
begin | |
setup | |
Stylus.compile content | |
rescue => e | |
puts "Stylus Exception: #{e.message}" | |
end | |
end | |
end | |
end |
Thanks for this. I'm using this on a Jekyll blog. I couldn't get it working but then I realized my mistake... I was putting my main.styl
inside my _styl
folder. I created a css
folder and moved main.styl
into that and left all the other individual stylus partial files inside _styl
and it worked :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A project I'm working on, a tool that converts stylus into sass or less or other precompiled CSS.
stylus-converter