sprockets

https://github.com/rails/sprockets

Ruby

Rack-based asset packaging system

Sprockets::Context#asset_data_uri

Returns a Base64-encoded `data:` URI with the contents of the
asset at the specified path, and marks that path as a dependency
of the current file.

Use `asset_data_uri` from ERB with CSS or JavaScript assets:

    #logo { background: url(<%= asset_data_uri 'logo.png' %>) }

    $('<img>').attr('src', '<%= asset_data_uri 'avatar.jpg' %>')

Source | Google | Stack overflow

Edit

git clone [email protected]:rails/sprockets.git

cd sprockets

open lib/sprockets/context.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Sprockets--Context-asset_data_uri-for-pr


# Commit to git

git add lib/sprockets/context.rbgit commit -m "better docs for Sprockets::Context#asset_data_uri"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Sprockets--Context-asset_data_uri-for-pr

hub pull-request


# Celebrate!