-
-
Save sukima/2925325 to your computer and use it in GitHub Desktop.
A trivial CoffeeScript.org -> Javascript plugin for OLDER OctoPress. Put this file in 'plugins/' and write a YAML header to your .coffee files (i.e. "---\nlayout:nil\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 | |
content = CoffeeScript.compile content | |
# OctoPress will pass all content though a RubyPants filter. | |
# RubyPants will conver quotes to smart quotes. | |
# RubyPants will ignore any convertions when content is surrounded by HTML <script> tags | |
# This adds HTML <script> tags to the output to prevent RubyPants from processing the JavaScript code. | |
<<EOS | |
// <script> To prevent OctoPress filtering through RubyPants ([See Gist][1]) | |
#{content} | |
// [1]: https://gist.github.com/2925325 | |
// </script> | |
EOS | |
rescue StandardError => e | |
puts "CoffeeScript error:" + e.message | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Hack is no longer required for latest OctoPress. Use this gist instead.