Created
April 22, 2010 11:30
-
-
Save xaviershay/375103 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| # 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' ] |
This file contains hidden or 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
| # 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