Last active
August 29, 2015 13:56
-
-
Save guilleiguaran/9211738 to your computer and use it in GitHub Desktop.
Sprockets Processor for paths fixing
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
| body{background-image:url("/assets/bg-ef8538157f3dc9558b9443c31ccd896c.jpg")} |
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
| body | |
| { | |
| background-image: url('/assets/bg.png'); | |
| } |
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
| class AssetPathProcessor < Sprockets::Processor | |
| def evaluate(context, locals) | |
| data.gsub(%r{["|']/assets/(.+)["|']}) do | |
| '"' + context.asset_path($1) + '"' | |
| end | |
| 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
| require 'asset_path_processor' | |
| Rails.application.assets.register_preprocessor('text/css', AssetPathProcessor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment