Created
August 29, 2012 23:50
-
-
Save johnbintz/3520579 to your computer and use it in GitHub Desktop.
add_t
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
Gem::Specification.new do |s| | |
s.name = 'add_t' | |
s.version = '0.1.0' | |
s.platform = Gem::Platform::RUBY | |
s.author = 'John Bintz' | |
s.email = '[email protected]' | |
s.summary = 'Filter JavaScript files for %{path} and replace it with the logical Sprockets path.' | |
s.description = 'Filter JavaScript files for %{path} and replace it with the logical Sprockets path.' | |
s.files = ['add_t.rb'] | |
s.require_path = '.' | |
s.add_dependency 'tilt' | |
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
require 'tilt' | |
class AddT < ::Tilt::Template | |
def prepare ; end | |
def evaluate(scope, locals, &block) | |
data.gsub('%{path}', scope.logical_path.split('/')[1..-1].join('.')) | |
end | |
class Engine < Rails::Engine | |
initializer "add_t.sprockets", :after => "sprockets.environment" do |app| | |
app.assets.register_preprocessor 'application/javascript', ::AddT | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment