Repository is archived
No commit activity in last 3 years
No release in over 3 years
Precompiles bundles of assets per controller or controller/action pair.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

< 4.2, >= 4.0
 Project Readme

RailsControllerAssets

Build Status Code Climate

This gems allows to automatically precompile bundles of assets per controller or controller/action pair.

It's great when you want to keep action or controller specific CSS/JavaScript in a separate file.

Usage

In your Gemfile:

gem 'rails-controller-assets'

Create new bundle files (eg. like application.css) for a PostsController:

In app/assets/stylesheets/posts.css:

.post-title { color: red }

In your application layout add to your stylesheets definition:

<%= stylesheet_link_tag 'application', *controller_stylesheets %>
<%= javascript_include_tag 'application', *controller_javascripts %>

And that's it!

The gem will look for bundle files that match:

  • {controller_name}.{js|css}
  • {controller_name}_{action_name}.{js|css}

Author

Brought to you by Piotr Usewicz.