function _less_attach_src in Less CSS Preprocessor 7.4
Same name and namespace in other branches
- 8 less.module \_less_attach_src()
- 7.3 less.module \_less_attach_src()
Add original .less file path as 'src' attribute to <link />.
Parameters
array $styles: CSS style tags after drupal_pre_render_styles() has run.
Return value
array Styles array with 'src' attributes on LESS files.
See also
1 string reference to '_less_attach_src'
- less_element_info_alter in ./
less.module - Implements hook_element_info_alter().
File
- ./
less.module, line 127 - Handles compiling of .less files.
Code
function _less_attach_src($styles) {
foreach (element_children($styles) as $key) {
// If its a <link />, then most likely its a compiled .less file.
if ($styles[$key]['#tag'] == 'link') {
// Hashes are generated based on the URL without the query portion.
$file_url_parts = drupal_parse_url($styles[$key]['#attributes']['href']);
// If we have a match, it means it is a compiled .less file.
if ($cache = cache_get('less:watch:' . drupal_hash_base64($file_url_parts['path']))) {
// Some inspectors allow 'src' attribute to open from a click.
$styles[$key]['#attributes']['src'] = url($cache->data['less']['input_file']);
}
}
}
return $styles;
}