public
Last active

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")

  • Download Gist
coffeescript_converter.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
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

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

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.