/
2_3.rb
56 lines (49 loc) · 1.51 KB
/
2_3.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#rails 2.x doesn't have railties so gona do this the long way
require "sass/plugin/rack" #unless defined?(Sass::Plugin::Rack)
module ActionController
class Base
def process_with_compass(*args)
Sass::Plugin.rails_controller = self
begin
process_without_compass(*args)
ensure
Sass::Plugin.rails_controller = nil
end
end
alias_method_chain :process, :compass
end
end
module Sass::Plugin
class << self
attr_accessor :rails_controller
end
end
module Compass::SassExtensions::Functions::Urls::ImageUrl
def image_url_with_rails_integration(path, only_path = Sass::Script::Bool.new(false), cache_buster = Sass::Script::Bool.new(true))
if (@controller = Sass::Plugin.rails_controller) && @controller.respond_to?(:request) && @controller.request
begin
if only_path.to_bool
Sass::Script::String.new image_path(path.value)
else
Sass::Script::String.new "url(#{image_path(path.value)})"
end
ensure
@controller = nil
end
else
image_url_without_rails_integration(path, only_path, cache_buster)
end
end
alias_method_chain :image_url, :rails_integration
end
class Sass::Script::Functions::EvaluationContext
include Sass::Script::Functions
private
include ActionView::Helpers::AssetTagHelper
end
unless Compass.detect_configuration_file.nil?
Compass.add_configuration(CompassRails.configuration)
CompassRails.initialize!
else
CompassRails.initialize!(CompassRails.configuration)
end