Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add asset helpers to facilitate generating asset urls via the asset p…
…ipeline.
- Loading branch information
1 parent
1352235
commit 95d5653
Showing
6 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module Sass | ||
module Rails | ||
module Helpers | ||
|
||
def asset_path(asset, kind) | ||
Sass::Script::String.new(public_path(asset.value, kind.value), true) | ||
end | ||
|
||
def asset_url(asset, kind) | ||
Sass::Script::String.new(%Q{url(#{public_path(asset.value, kind.value)})}) | ||
end | ||
|
||
[:image, :font, :video, :audio, :javascript, :stylesheet].each do |asset_class| | ||
class_eval %Q{ | ||
def #{asset_class}_path(asset) | ||
asset_path(asset, Sass::Script::String.new("#{asset_class}")) | ||
end | ||
def #{asset_class}_url(asset) | ||
asset_url(asset, Sass::Script::String.new("#{asset_class}")) | ||
end | ||
}, __FILE__, __LINE__ - 7 | ||
This comment has been minimized.
Sorry, something went wrong. |
||
end | ||
|
||
protected | ||
def public_path(asset, kind) | ||
options[:custom][:resolver].public_path(asset, kind.pluralize) | ||
end | ||
end | ||
end | ||
end | ||
|
||
module Sass | ||
module Script | ||
module Functions | ||
include Sass::Rails::Helpers | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
should be -6 here