Skip to content

Instantly share code, notes, and snippets.

@humphreybc
Created October 19, 2017 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save humphreybc/b0d5c0b6cffc186c50e50ed75d1fdca5 to your computer and use it in GitHub Desktop.
Save humphreybc/b0d5c0b6cffc186c50e50ed75d1fdca5 to your computer and use it in GitHub Desktop.
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