Created
October 19, 2017 03:54
-
-
Save humphreybc/b0d5c0b6cffc186c50e50ed75d1fdca5 to your computer and use it in GitHub Desktop.
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
module AssetsHelper | |
def inline_file(path) | |
if assets = Rails.application.assets | |
asset = assets.find_asset(path) | |
return '' unless asset | |
asset.source | |
else | |
File.read(File.join(Rails.root, 'public', asset_path(path))) | |
end | |
end | |
def inline_css(path) | |
"<style>#{inline_file path}</style>".html_safe | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment