Skip to content

Instantly share code, notes, and snippets.

@xaviershay
Created April 22, 2010 11:30
Show Gist options
  • Select an option

  • Save xaviershay/375103 to your computer and use it in GitHub Desktop.

Select an option

Save xaviershay/375103 to your computer and use it in GitHub Desktop.
# A coffee-script filter for nanoc3
require 'open3'
require 'win32/open3' if RUBY_PLATFORM.match /win32/
class CoffeeFilter < Nanoc3::Filter
identifier :coffee
def run(content, params = {})
output = ''
command = 'coffee -s -p -l'
Open3.popen3(command) do |stdin, stdout, stderr|
stdin.puts content
stdin.close
output = stdout.read.strip
[stdout, stderr].each { |io| io.close }
end
output
end
end
# Be sure to add your coffee extension at the end
text_extensions: [ 'css', 'erb', 'haml', 'htm', 'html', 'js', 'less', 'markdown', 'md', 'php', 'rb', 'sass', 'txt', 'coffee' ]
# Compile both coffee and js, co-mingled in the same directory
compile '/js/*' do
case item[:extension]
when 'coffee'
filter :coffee
when 'js'
# Nothing
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment