Hello,
Can anyone provide guidance on whether or not there is an idiomatic
way to create a very small set (say, <= 10 declarations) of dynamic CSS
with RoR?
Method 1: Embedding a style
tag into the page (whether directly or
rendered from a partial) in application.html.erb. This implies that the
“stylesheet” is either spaghetti’d into application.html.erb (which is
messier and more brittle), or is an actual partial living in
app/views/layouts/
(which violates the Principle of Least
Astonishment). IMO this is probably the most practical solution
(balancing maintenance effort with runtime performance) but smells to
high-heaven.
Method 2: Linking to a second, dynamic, stylesheet (dynamic.css.erb)
after application.css. Clean and clear-cut, but the additional GET,
especially for such little content, seems ridiculous.
Method 3: Morphing application.css into application.css.erb, using
require_self, and appending the dynamic styles into that file. Very
“direct” intent, but this would require the entire stylesheet manifest
to be preprocessed on every request - no bueno.
Which is considered idiomatic? Perhaps there are other methods I’ve
not listed? Is there a section of the Asset Pipeline manual that I’ve
missed which addresses this specific question?
Cheers,
-Chris
–
Chris T.
Forge Software
[email protected]
800.875.3048 x1
“Perfection is achieved not when there is nothing more to add, but
when there is nothing left to take away.”
-Antoine de Saint-Exupery