Include all stylesheets in a subdirectory in Rails

In my stylesheet I have application.css, ie_fixes.cssand themes. There are about twenty css files in the themes directory. All of these stylesheets, minus ie_fixes, are necessary for widespread use, therefore they are included in the application layout. The value of ie_fixes.css should only be included if the user browser is IE. I would like to be able to include everything in the themes folder in one, compressed line of code.

Rails provides an easy way to include all stylesheets by following these steps:

stylesheet_link_tag :all, :recursive => true

Unusually, but the problem is that it includes mine ie_fixes.cssin every browser, causing my conditional IE comments out of the water. So my question is, is there an easy way to include all stylesheets for a subdirectory without specifying each file name?

I tried different options to stylesheet_link_tag 'themes/', :recursive => trueno avail. It seems that all this method preends the stylehseet directory and adds .css if necessary.

+3
source share
3 answers

After scouring a web page similar to age and not finding anything, I finally decided to come up with my own way. I intend to use this again in future projects, so I created it as a plugin.

http://github.com/thorncp/improved-includes

+1
source

, CSS ( IE one) . IE .

, 20 HTTP- (2 . ) .

+2

Could you just include it in another directory instead and in your IE conditional statement in the head tag point it to this directory?

This will still allow you to get stylish style sheets: all when you need it.

+1
source

Source: https://habr.com/ru/post/1726759/


All Articles