--- esi.theme.orig.inc	2010-08-24 23:23:36.000000000 +0200
+++ esi.theme.inc	2010-11-21 07:11:38.000000000 +0100
@@ -13,20 +13,28 @@ function esi__theme_blocks($region) {
   // load our helper file.
   require_once(dirname(__FILE__) . '/esi.inc');
   
-  if ($list = block_list($region)) {
-    foreach ($list as $key => $block) {
-      // if ESI's enabled on the block, add an ESI tag instead of block content.
-      $esi_config = _esi__block_settings($block->module, $block->delta);
-      $output .= $esi_config->enabled
-        ? theme('esi_tag', $block)
-        : theme('block', $block);
+  // if context module is used, render blocks through that
+  if (module_exists("context")){  
+    if ($plugin = context_get_plugin('reaction', 'block')) {
+      return $plugin->execute($region);
     }
+	} else {
+    if ($list = block_list($region)) {
+      foreach ($list as $key => $block) {
+        // if ESI's enabled on the block, add an ESI tag instead of block content.
+        $esi_config = _esi__block_settings($block->module, $block->delta);
+        $output .= $esi_config->enabled
+          ? theme('esi_tag', $block)
+          : theme('block', $block);
+      }
+    }
+    
+    // Add any content assigned to this region through drupal_set_content() calls.
+    $output .= drupal_get_content($region);
+    
+    return $output;
   }
-
-  // Add any content assigned to this region through drupal_set_content() calls.
-  $output .= drupal_get_content($region);
-
-  return $output;
+  
 }
 
 
