Skip to content

Instantly share code, notes, and snippets.

@olivoil
Forked from phaer/coffeescript_converter.rb
Created September 9, 2011 20:54
Show Gist options
  • Save olivoil/1207306 to your computer and use it in GitHub Desktop.
Save olivoil/1207306 to your computer and use it in GitHub Desktop.
A trivial CoffeeScript.org -> Javascript plugin for jekyll ( https://github.com/mojombo/jekyll ). Put this file in '_plugins/' and write a YAML header to your .coffee files (i.e. "---\n---\n")
module Jekyll
require 'coffee-script'
class CoffeeScriptConverter < Converter
safe true
priority :normal
def matches(ext)
ext =~ /coffee/i
end
def output_ext(ext)
".js"
end
def convert(content)
begin
CoffeeScript.compile content
rescue StandardError => e
puts "CoffeeScript error:" + e.message
end
end
end
end
@matthodan
Copy link

If you want a more comprehensive asset pipeline solution, you might consider Jekyll Asset Pipeline which will convert CoffeeScript, Sass, Less or any other language via an extension. It can also compress assets via Yahoo's YUI Compressor or Google's Closure Compiler.

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