-
-
Save RedHatter/54d4b2fa0a1c14c253846f2d3867683a to your computer and use it in GitHub Desktop.
Stylus plugin for Jekyll
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
require 'shellwords' | |
module Jekyll | |
class StylusConverter < Converter | |
safe true | |
def matches(ext) | |
ext =~ /\.styl/i | |
end | |
def output_ext(ext) | |
'.css' | |
end | |
def convert(content) | |
begin | |
command = Shellwords.escape content | |
`echo #{command} | stylus` | |
rescue => e | |
puts "Stylus Exception: #{e.message}" | |
end | |
end | |
end | |
class StylusBlock < Liquid::Block | |
def initialize(tag_name, text, tokens) | |
super | |
end | |
def render(context) | |
content = super | |
begin | |
command = Shellwords.escape content | |
`echo #{command} | stylus -p` | |
rescue => e | |
puts "Stylus Exception: #{e.message}" | |
end | |
end | |
end | |
end | |
Liquid::Template.register_tag('stylus', Jekyll::StylusBlock) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment