diff --git a/insert_view.module b/insert_view.module
index 8924757..42283f5 100644
--- a/insert_view.module
+++ b/insert_view.module
@@ -49,16 +49,26 @@ Valid examples:
  * Helper function to replace the tag syntax with the actual view.
  */
 function _insert_view_substitute_tags($text, $format) {
+  $heap = drupal_static(__FUNCTION__, array());
   if (preg_match_all("/\[view:([^=\]]+)=?([^=\]]+)?=?([^\]]*)?\]/i", $text, $match)) {
     foreach ($match[0] as $key => $value) {
-      $view_name = $match[1][$key];
-      $display_id = ($match[2][$key] && !is_numeric($match[2][$key])) ? $match[2][$key] : 'default';
-      $args = $match[3][$key];
+      // Return an empty string if recursively calling itself.
+      if (isset($heap[$value])) {
+        $search[] = $value;
+        $replace[] = '';
+      }
+      else {
+        $heap[$value] = TRUE;
+        $view_name = $match[1][$key];
+        $display_id = ($match[2][$key] && !is_numeric($match[2][$key])) ? $match[2][$key] : 'default';
+        $args = $match[3][$key];
 
-      $view_output = insert_view($view_name, $display_id, $args);
+        $view_output = insert_view($view_name, $display_id, $args);
 
-      $search[] = $value;
-      $replace[] = !empty($view_output) ? $view_output : '';
+        $search[] = $value;
+        $replace[] = !empty($view_output) ? $view_output : '';
+        unset($heap[$value]);
+      }
     }
     return str_replace($search, $replace, $text);
   }
