Sinatra::AssetHelpers
Pipeline-agnostic Asset Helpers for Sinatra
Installation
Add this line to your application's Gemfile:
gem 'sinatra-asset_helpers', require: 'sinatra/asset_helpers'
And then execute:
$ bundle
Usage
Once you add it to your modular Sinatra App:
class App < Sinatra::Base
register Sinatra::AssetHelpers
end
You will be able to use the following helper methods in your templates and layout files:
stylesheet_tag('app.css, 'media')
# => <link href="/assets/app.css" media="screen" rel="stylesheet">
javascript_tag('app.js')
# => <script src="/assets/app.js"></script>
image_tag('image.png', 'image alt', 'image title')
# => <img src="/assets/image.png" alt="image alt" title="image title">
Options
You can set the following options in Sinatra to configure Sinatra::AssetHelpers
:
set :assets_path, 'myassets' # defaults to: 'assets'
set :assets_host, 'https://assets.example.com' # defaults to: ENV['ASSETS_HOST']
set :manifest_path, '/path/to/manifest.json' # defaults to: "#{settings.root}/public/assets/manifest.json"
Contributing
- Fork it ( http://github.com/
/sinatra-asset_helpers/fork ) - Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request