Skip to content

Commit

Permalink
override function methods to use appropriate value classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bolandrm committed Sep 28, 2018
1 parent 3dd4127 commit c314d1c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
24 changes: 24 additions & 0 deletions lib/sassc/rails/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,30 @@ def safe_merge(key, left, right)
right
end
end

# The methods in the Functions module were copied here from sprockets in order to
# override the Value class names (e.g. ::SassC::Script::Value::String)
module Functions
def asset_path(path, options = {})
path = path.value

path, _, query, fragment = URI.split(path)[5..8]
path = sprockets_context.asset_path(path, options)
query = "?#{query}" if query
fragment = "##{fragment}" if fragment

::SassC::Script::Value::String.new("#{path}#{query}#{fragment}", :string)
end

def asset_url(path, options = {})
::SassC::Script::Value::String.new("url(#{asset_path(path, options).value})")
end

def asset_data_url(path)
url = sprockets_context.asset_data_uri(path.value)
::SassC::Script::Value::String.new("url(" + url + ")")
end
end
end

class ScssTemplate < SassTemplate
Expand Down
3 changes: 0 additions & 3 deletions test/sassc_rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ def test_all_sass_asset_paths_work
end

def test_sass_asset_paths_work
# FIX before merging. this is causing segfault
skip

initialize!

css_output = render_asset("helpers_test.css")
Expand Down

0 comments on commit c314d1c

Please sign in to comment.