What does it do exactly?
Say you have controller
Admin::User::CommentsController, which has action
show and you have the following files under your
more: support for partials
CssJsTree also automatically includes css and js files that correspond to partials that get rendered for each view. It will only include each css and js once per partial. So if you have in your view something like:
... <% 2.times do %> <%= render :partial '/shared/foo' %> <% end> <%= render :partial '/shared/bar' %> ...
And you have the following files under
_bar.js files will each be included once into your view. It works the same way with your css files.
Installation and Usage
Install the plugin:
rails plugin install firstname.lastname@example.org:charleseff/css_js_tree.git
Then, in application_controller.rb add this line:
and add to your layout file:
<html> <head> <%= css_tree %> <%= js_tree %> </head> ... </html>
That's it. Now, any css files added to your
public/stylesheets folder and js files added to your
You can access the CssJsTree configuration by opening a CssJsTree.configure block inside your application.rb file like so:
class Application < Rails::Application ... config.after_initialize do CssJsTree.configure do |config| config[:css_tree_location] = 'generated' config[:js_tree_location] = 'tree' ... end end end
This is useful when you have css files that you want to reside outside of this structure, or when you're using Sass to generate your css files.
Rails caching key prefix can be adjusted