Project

tension

0.0
No commit activity in last 3 years
No release in over 3 years
Tension brings some sanity to Rails's CSS & JS organization for modern front–end development.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 3.2
 Project Readme

Tension

Tighten up Rails's asset pipeline for CSS & JS.

Rails's asset pipeline is smart and well–implemented under the hood, but it can be a challenge to organize your CSS and JavaScript so that you don't have to struggle to maintain which files get compiled, where they live, and how they're included in views and templates.

Tension helps you out. It takes Rails's existing controller/view file structure and applies it to JavaScript and CSS assets as well. Let's take a sample Rails app:

app
+ assets
+ controllers
  + account
  + api
  + blog
    + posts_controller.rb
+ models
+ views
  + account
  + api
  + blog
    + posts
      + index.html.erb
  + layouts
    + blog.html.erb

The standard structure Rails enforces is modulecontrolleraction. For the PostsController, the action logic is tucked away alongside other actions in posts_controller.rb, but its view is a separate file namespaced under the blog module and posts controller.

This is a logical, intuitive structure. Our assets should follow it too.

Using Rails's asset pipeline you can drop an asset anywhere within the assets directory and Rails will compile and serve it, but Rails enforces no logical structure on your files. This leads to messy, hard-to-maintain code, and it gets worse when you precompile assets in production.

...