I propose some changes to the process of inlining stylesheet data from files specified in a theme.
As it is now, _css_delivery_load_inline_css_theme() function gets the contents of CSS file and invokes drupal_add_css() with this now static content as 'inline' data.
In contrast, LESS module relies on hook_element_info_alter() to inject a 'pre_process' handler that replaces references to LESS source file with the location of resulting CSS file.
In the included patch I changed the 'drupal_add_css()' call to add 'file' type data initially (which gets processed by other modules if needed, e.g. LESS) and afterwards a similar hook converts file reference to inline CSS bringing it back to the module's regular flow.
This added complexity has an evident improvement of supporting LESS files but might also help cooperate with other modules that are pre-processing stylesheets.
P.S. The above hook sets the order of pre_render functions by placing itself first with array_unshift(). LESS module fires later (alphabetically) and does the same, thus cutting first in line (which is the correct order). However, to enforce this order it might be better to adjust the modules's weight as per https://www.drupal.org/node/110238
| Comment | File | Size | Author |
|---|---|---|---|
| css_delivery-inline-less-fix-2429583-1.patch | 2.9 KB | kurapov |
Comments
Comment #2
nwom commentedSetting to "Needs review" since a patch is attached.