Skip to content

Instantly share code, notes, and snippets.

@stovak
Created April 25, 2012 02:35
Show Gist options
  • Save stovak/2485702 to your computer and use it in GitHub Desktop.
Save stovak/2485702 to your computer and use it in GitHub Desktop.
patch drupal less module with pre and post process hooks
diff --git a/less.module b/less.module
index 20c27317ba2be24b139a0a193dcaa4cad6694ff2..5c269ed4405c66171eb526048cdded2727d0f236 100644
--- a/less.module
+++ b/less.module
@@ -107,7 +107,21 @@ function _less_pre_render($styles) {
$data = preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', '_drupal_build_css_path', $contents);
try {
- $output_data = $less->parse($data);
+ $mods = module_implements("less_css_preprocess");
+ if (!empty($mods)) {
+ foreach ($mods as $mod) {
+ $data = call_user_func("{$mod}_less_css_preprocess", $data);
+ }
+ }
+
+ $output_data = $less->parse($data);
+
+ $mods = module_implements("less_css_postprocess");
+ if (!empty($mods)) {
+ foreach ($mods as $mod) {
+ $output_data = call_user_func("{$mod}_less_css_postprocess", $data);
+ }
+ }
file_unmanaged_save_data($output_data, $output_file, FILE_EXISTS_REPLACE);
}
catch (Exception $e) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment