0.0
No commit activity in last 3 years
No release in over 3 years
Include assets in your views with a single line of code.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3.0
~> 4.7.0
 Project Readme

Build Status Code Climate Code Climate

What is assets-include-ruby?

Assets-include is a Ruby wrapper around Assets-Include for including your assets in HTML views.

See example apps for real-world use cases.

Usage

What are the requirements?

Ruby 1.9.3+
Node.js 0.8.0+

How to install assets-include-ruby?

gem install assets_include

How to use assets-include-ruby?

With Sinatra:

require 'sinatra'
require 'assets_include'

# Adds assets.(group|list|inline) helpers
helpers AssetsInclude.helpers

get '/' do
  erb :index
end

__END__

@@ layout
<html>
<head>
  <%= assets.group('stylesheets/all.css') %>
</head>
<body>
  <%= yield %>
  <%= assets.group('javascripts/all.js') %>
</body>
</html>

@@ index
<h1>Yay, all assets are included!</h1>

AssetsInclude.helpers accepts a configuration block exposing the following variables:

  • bundled - whether to serve bundled (production) or expanded (development) assets. Defaults based on ENV['RACK_ENV'] value.
  • config - path to configuration file, defaults to ./assets.yml
  • root - root path of all assets, defaults to ./public under config's path
  • cache_boosters - true for cache boosters (timestamp in dev mode, md5 for bundled, production files)
  • asset_hosts - prefixes all paths with given asset host(s)
  • loading_mode - async or defer for JavaScript assets' loading mode

and adds the following methods to your views:

  • assets.group(locator) - returns a list of <script> or <link> tags for JavaScript or CSS assets respectively
  • assets.inline(locator) - returns inlined JavaScript or CSS assets. In development mode works the same way as #group.
  • assets.list(locator) - returns an array of assets files to easily embed them into JavaScript or data attributes.
  • assets.reset - empties includer's cache

License

Assets-include-ruby is released under the MIT License.