Created
May 6, 2011 22:39
-
-
Save phaer/959938 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")
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 '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 |
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
According to this post on SO OctoPress HTML escapes the output.
This fork fixes that OctoPress issue: https://gist.github.com/2925325
EDIT: The above fork is only needed on older versions of Octopress. Latest works with this gist