[limb-svn] r6793 - in 3.x/trunk/limb/macro: src/compiler src/tags/core tests/cases/tags/core

svn at limb-project.com svn at limb-project.com
Mon Feb 11 18:24:56 MSK 2008


Author: serega
Date: 2008-02-11 18:24:56 +0300 (Mon, 11 Feb 2008)
New Revision: 6793
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6793

Added:
   3.x/trunk/limb/macro/src/tags/core/insert.tag.php
   3.x/trunk/limb/macro/src/tags/core/insert_into.tag.php
   3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroIncludeTagBCTest.class.php
   3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroInsertTagTest.class.php
   3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroWrapTagBCTest.class.php
Removed:
   3.x/trunk/limb/macro/src/tags/core/include.tag.php
   3.x/trunk/limb/macro/src/tags/core/include_into.tag.php
   3.x/trunk/limb/macro/src/tags/core/wrap.tag.php
   3.x/trunk/limb/macro/src/tags/core/wrap_into.tag.php
   3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroIncludeTagTest.class.php
   3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroWrapTagTest.class.php
Modified:
   3.x/trunk/limb/macro/src/compiler/lmbMacroTag.class.php
   3.x/trunk/limb/macro/src/compiler/lmbMacroTagAttribute.class.php
   3.x/trunk/limb/macro/src/compiler/lmbMacroTemplateExecutor.class.php
Log:
-- lmbMacroTag :: getAttributeObject() added
-- lmbMacroTagAttribute :: setName($new_name) added
-- new {{insert}} tag added that is a composite tag for both {{wrap}} and {{include}} tags. {{insert}} can do the same things as {{wrap}} and {{include}} tags. The main changes in pair of {{insert}}/{{insert:into}} are in determining what if you have a dynamic wrapping or static one. Now if {{into}} tag find the slot at compiletime it considers that this is a static wrapping. Old version asked for nearest parent {{wrap}} tag if "file" attribute is a variable. It turned out that the old variant does not work for a bit more complex cases. BC should be 100% preserved.

Modified: 3.x/trunk/limb/macro/src/compiler/lmbMacroTag.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/compiler/lmbMacroTag.class.php	2008-02-11 14:54:11 UTC (rev 6792)
+++ 3.x/trunk/limb/macro/src/compiler/lmbMacroTag.class.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -69,7 +69,15 @@
 
     return $this->attributes[strtolower($name)]->getValue();
   }
+  
+  function getAttributeObject($name)
+  {
+    if(!array_key_exists(strtolower($name), $this->attributes))
+      return;
 
+    return $this->attributes[strtolower($name)];
+  }
+
   function getEscaped($name)
   {
     if(!$this->has($name))

Modified: 3.x/trunk/limb/macro/src/compiler/lmbMacroTagAttribute.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/compiler/lmbMacroTagAttribute.class.php	2008-02-11 14:54:11 UTC (rev 6792)
+++ 3.x/trunk/limb/macro/src/compiler/lmbMacroTagAttribute.class.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -30,6 +30,11 @@
   {
     return $this->name;
   }
+  
+  function setName($name)
+  {
+    $this->name = $name;
+  }
 
   function addTextFragment($text)
   {

Modified: 3.x/trunk/limb/macro/src/compiler/lmbMacroTemplateExecutor.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/compiler/lmbMacroTemplateExecutor.class.php	2008-02-11 14:54:11 UTC (rev 6792)
+++ 3.x/trunk/limb/macro/src/compiler/lmbMacroTemplateExecutor.class.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -68,6 +68,7 @@
     $template->setVars(get_object_vars($this));//global template vars
     foreach($slots_handlers as $name => $handler)
       $template->set('__slot_handler_' . $name, $handler);
+    $template->setChildExecutor($this);//from now we consider the wrapper to be a master variable context
     echo $template->render($vars);//local template vars
   }
 

Deleted: 3.x/trunk/limb/macro/src/tags/core/include.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/include.tag.php	2008-02-11 14:54:11 UTC (rev 6792)
+++ 3.x/trunk/limb/macro/src/tags/core/include.tag.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -1,94 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-/**
- * class lmbMacroIncludeTag.
- *
- * @tag include
- * @req_attributes file
- * @package macro
- * @version $Id$
- */
-class lmbMacroIncludeTag extends lmbMacroTag
-{
-  function preParse($compiler)
-  {
-    parent :: preParse($compiler);
-
-    if(!$this->isDynamicInclude())
-    {
-      $compiler->parseTemplate($this->get('file'), $this);
-    }
-  }
-
-  function isDynamicInclude()
-  {
-    return $this->isDynamic('file');
-  }
-
-  protected function _generateContent($code)
-  {
-    if($this->isDynamicInclude())
-      $this->_generateDynamicaly($code);
-    else
-      $this->_generateStaticaly($code);
-  }
-
-  function _generateDynamicaly($code)
-  {
-    $handlers_str = 'array(';
-    $methods = array();
-
-    //collecting {{into}} tags
-    if($intos = $this->_collectIntos())
-    {
-      foreach($intos as $into)
-      {
-        $args = $code->generateVar(); 
-        $methods[$into->get('slot')] = $code->beginMethod('__slotHandler'. uniqid(), array($args . '= array()'));
-        $code->writePHP("if($args) extract($args);"); 
-        $into->generateNow($code);
-        $code->endMethod();
-      }
-    }
-
-    foreach($methods as $slot => $method)
-      $handlers_str .= '"' . $slot . '"' . ' => array($this, "' . $method . '"),';
-
-    $handlers_str .= ')';
-
-    $arg_str = $this->attributesIntoArrayString();
-
-    $code->writePHP('$this->includeTemplate(' . $this->get('file') . ', ' . $arg_str . ','. $handlers_str . ');');
-  }
-  
-  protected function _collectIntos()
-  {
-    return $this->findChildrenByClass('lmbMacroIncludeIntoTag');
-  }
-
-  function _generateStaticaly($code)
-  {
-    if($this->getBool('inline'))
-      parent :: _generateContent($code);
-    else
-    {
-      static $counter = 1;
-  
-      list($keys, $vals) = $this->attributesIntoArgs();
-  
-      $method = $code->beginMethod('__staticInclude' . ($counter++), $keys);
-      parent :: _generateContent($code);
-      $code->endMethod();
-  
-      $code->writePHP('$this->' . $method . '(' . implode(', ', $vals) . ');');
-    }
-  }
-}
-

Deleted: 3.x/trunk/limb/macro/src/tags/core/include_into.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/include_into.tag.php	2008-02-11 14:54:11 UTC (rev 6792)
+++ 3.x/trunk/limb/macro/src/tags/core/include_into.tag.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -1,67 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-/**
- * class lmbMacroIntoTag.
- *
- * @tag include:into
- * @aliases include_into
- * @package macro
- * @version $Id$
- */
-class lmbMacroIncludeIntoTag extends lmbMacroTag
-{
-  protected $is_dynamic;
-  
-  function preParse($compiler)
-  {
-    parent :: preParse($compiler);
-    
-    if($parent = $this->findParentByClass('lmbMacroIncludeTag'))
-      $this->is_dynamic = $parent->isDynamicInclude();  
-    else
-    {
-      $parent = $this->findRoot();
-      $this->is_dynamic = false;  
-    }
-    
-    if(!$this->is_dynamic)
-    {
-      $tree_builder = $compiler->getTreeBuilder();
-      $this->_insert($parent, $tree_builder, $this->get('slot'));
-    }
-  }
-
-  function _insert($parent, $tree_builder, $point)
-  {
-    $insertionPoint = $parent->findChild($point);
-    if(empty($insertionPoint))
-    {
-      $params = array('slot' => $point);
-      $params['parent_wrap_tag_file'] = $parent->getTemplateFile();
-      $params['parent_wrap_tag_line'] = $parent->getTemplateLine();
-
-      $this->raise('Wrap slot not found', $params);
-    }
-
-    $tree_builder->pushCursor($insertionPoint, $this->location);
-  }
-  
-  function generate($code)
-  {
-    if(!$this->is_dynamic)
-      parent :: generate($code);
-  }
-  
-  function generateNow($code)
-  {
-    parent :: generate($code); 
-  }
-}
-

Added: 3.x/trunk/limb/macro/src/tags/core/insert.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/insert.tag.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/insert.tag.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -0,0 +1,139 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+/**
+ * class lmbMacroWrapTag.
+ *
+ * @tag insert
+ * @aliases wrap,include
+ * @req_attributes file
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroInsertTag extends lmbMacroTag
+{
+  protected $is_dynamic = false;
+
+  function preParse($compiler)
+  {
+    if($this->has('in'))
+      $this->set('into', $this->get('in'));
+
+    if($this->has('with')) // for BC with old {{wrap}} tag
+    {
+      $att = $this->getAttributeObject('with');
+      $att->setName('file');
+      $this->add($att);
+    }
+
+    parent :: preParse($compiler);
+    
+    if($this->isDynamic('file'))
+      $this->is_dynamic = true;
+
+    if(!$this->is_dynamic)
+    {
+      $file = $this->get('file');
+      $compiler->parseTemplate($file, $this);
+
+      //if there's no 'into' attribute we consider that {{insert:into}} tags used instead
+      if($into = $this->get('into'))
+      {
+        $tree_builder = $compiler->getTreeBuilder();
+        $this->_insert($this, $tree_builder, $into);
+      }
+    }
+  }
+
+  function _insert($wrapper, $tree_builder, $point)
+  {
+    $insertionPoint = $wrapper->findChild($point);
+    if(empty($insertionPoint))
+    {
+      $params = array('slot' => $point);
+      if($wrapper !== $this)
+      {
+        $params['parent_wrap_tag_file'] = $wrapper->getTemplateFile();
+        $params['parent_wrap_tag_line'] = $wrapper->getTemplateLine();
+      }
+
+      $this->raise('Wrap slot not found', $params);
+    }
+
+    $tree_builder->pushCursor($insertionPoint, $this->location);
+  }
+
+  protected function _collectIntos()
+  {
+    return $this->findChildrenByClass('lmbMacroInsertIntoTag');
+  }
+
+  protected function _generateContent($code)
+  {
+    if($this->is_dynamic)
+      $this->_generateDynamicaly($code);
+    else
+      $this->_generateStaticaly($code);
+  }
+
+  function _generateDynamicaly($code)
+  {
+    $handlers_str = 'array(';
+    $methods = array();
+
+    //collecting {{into}} tags
+    if($intos = $this->_collectIntos())
+    {
+      foreach($intos as $into)
+      {
+        $args = $code->generateVar(); 
+        $methods[$into->get('slot')] = $code->beginMethod('__slotHandler'. uniqid(), array($args . '= array()'));
+        $code->writePHP("if($args) extract($args);"); 
+        $into->generateNow($code);
+        $code->endMethod();
+      }
+    }
+    elseif($this->has('into'))
+    {
+      $args = $code->generateVar(); 
+      $methods[$this->get('into')] = $code->beginMethod('__slotHandler'. uniqid(), array($args . '= array()'));
+      $code->writePHP("if($args) extract($args);"); 
+      parent :: _generateContent($code);
+      $code->endMethod();
+    }
+
+    foreach($methods as $slot => $method)
+      $handlers_str .= '"' . $slot . '"' . ' => array($this, "' . $method . '"),';
+
+    $handlers_str .= ')';
+
+    $arg_str = $this->attributesIntoArrayString();
+
+    $code->writePHP('$this->includeTemplate(' . $this->get('file') . ', ' . $arg_str . ','. $handlers_str . ');');
+  }  
+  
+  function _generateStaticaly($code)
+  {
+    if($this->getBool('inline'))
+      parent :: _generateContent($code);
+    else
+    {
+      static $counter = 1;
+  
+      list($keys, $vals) = $this->attributesIntoArgs();
+  
+      $method = $code->beginMethod('__staticInclude' . ($counter++), $keys);
+      parent :: _generateContent($code);
+      $code->endMethod();
+  
+      $code->writePHP('$this->' . $method . '(' . implode(', ', $vals) . ');');
+    }
+  }
+}
+

Added: 3.x/trunk/limb/macro/src/tags/core/insert_into.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/insert_into.tag.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/insert_into.tag.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -0,0 +1,50 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+/**
+ * class lmbMacroIntoTag.
+ *
+ * @tag insert:into
+ * @aliases into, wrap:into, include:into  
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroInsertIntoTag extends lmbMacroTag
+{
+  protected $slot_node;
+  protected $is_dynamic;
+  
+  function preParse($compiler)
+  {
+    parent :: preParse($compiler);
+    
+    if($slot_node = $this->parent->findUpChild($this->get('slot')))
+      $this->is_dynamic = false;
+    else
+      $this->is_dynamic = true;
+    
+    if(!$this->is_dynamic)
+    {
+      $tree_builder = $compiler->getTreeBuilder();
+      $tree_builder->pushCursor($slot_node, $this->location);
+    }
+  }
+
+  function generate($code)
+  {
+    if(!$this->is_dynamic)
+      parent :: generate($code);
+  }
+
+  function generateNow($code)
+  {
+    parent :: generate($code); 
+  }
+}
+

Deleted: 3.x/trunk/limb/macro/src/tags/core/wrap.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/wrap.tag.php	2008-02-11 14:54:11 UTC (rev 6792)
+++ 3.x/trunk/limb/macro/src/tags/core/wrap.tag.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -1,113 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-/**
- * class lmbMacroWrapTag.
- *
- * @tag wrap
- * @req_attributes with
- * @package macro
- * @version $Id$
- */
-class lmbMacroWrapTag extends lmbMacroTag
-{
-  protected $is_dynamic = false;
-
-  function preParse($compiler)
-  {
-    parent :: preParse($compiler);
-    
-    if($this->has('in'))
-      $this->set('into', $this->get('in'));
-
-    if($this->isDynamic('with'))
-      $this->is_dynamic = true;
-
-    if(!$this->is_dynamic)
-    {
-      $file = $this->get('with');
-      $compiler->parseTemplate($file, $this);
-
-      //if there's no 'into' attribute we consider that {{into}} tags used instead
-      if($into = $this->get('into'))
-      {
-        $tree_builder = $compiler->getTreeBuilder();
-        $this->_insert($this, $tree_builder, $into);
-      }
-    }
-  }
-
-  function _insert($wrapper, $tree_builder, $point)
-  {
-    $insertionPoint = $wrapper->findChild($point);
-    if(empty($insertionPoint))
-    {
-      $params = array('slot' => $point);
-      if($wrapper !== $this)
-      {
-        $params['parent_wrap_tag_file'] = $wrapper->getTemplateFile();
-        $params['parent_wrap_tag_line'] = $wrapper->getTemplateLine();
-      }
-
-      $this->raise('Wrap slot not found', $params);
-    }
-
-    $tree_builder->pushCursor($insertionPoint, $this->location);
-  }
-
-  function isDynamicWrap()
-  {
-    return $this->is_dynamic;
-  }
-
-  protected function _collectIntos()
-  {
-    return $this->findChildrenByClass('lmbMacroWrapIntoTag');
-  }
-
-  protected function _generateContent($code)
-  {
-    if($this->is_dynamic)
-    {
-      $handlers_str = 'array(';
-      $methods = array();
-
-      //collecting {{into}} tags
-      if($intos = $this->_collectIntos())
-      {
-        foreach($intos as $into)
-        {
-          $args = $code->generateVar(); 
-          $methods[$into->get('slot')] = $code->beginMethod('__slotHandler'. uniqid(), array($args . '= array()'));
-          $code->writePHP("if($args) extract($args);"); 
-          $into->generateNow($code);
-          $code->endMethod();
-        }
-      }
-      else
-      {
-        $args = $code->generateVar(); 
-        $methods[$this->get('into')] = $code->beginMethod('__slotHandler'. uniqid(), array($args . '= array()'));
-        $code->writePHP("if($args) extract($args);"); 
-        parent :: _generateContent($code);
-        $code->endMethod();
-      }
-
-      foreach($methods as $slot => $method)
-        $handlers_str .= '"' . $slot . '"' . ' => array($this, "' . $method . '"),';
-
-      $handlers_str .= ')';
-
-      $code->writePHP('$this->wrapTemplate(' . $this->getEscaped('with') . ', ' . $handlers_str . ');');
-    }
-    else
-      parent :: _generateContent($code);
-  }
-}
-

Deleted: 3.x/trunk/limb/macro/src/tags/core/wrap_into.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/wrap_into.tag.php	2008-02-11 14:54:11 UTC (rev 6792)
+++ 3.x/trunk/limb/macro/src/tags/core/wrap_into.tag.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -1,72 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-/**
- * class lmbMacroIntoTag.
- *
- * @tag wrap:into
- * @aliases into, wrap_into
- * @package macro
- * @version $Id$
- */
-class lmbMacroWrapIntoTag extends lmbMacroTag
-{
-  protected $is_dynamic;
-  
-  function preParse($compiler)
-  {
-    parent :: preParse($compiler);
-    
-    if($wrapper = $this->findParentByClass('lmbMacroWrapTag'))
-    {
-      $this->is_dynamic = $wrapper->isDynamicWrap();  
-    }
-    else
-    {
-      $wrapper = $this->findRoot();
-      $this->is_dynamic = false;  
-    }
-    
-    if(!$this->is_dynamic)
-    {
-      $tree_builder = $compiler->getTreeBuilder();
-      $this->_insert($wrapper, $tree_builder, $this->get('slot'));
-    }
-  }
-
-  function _insert($wrapper, $tree_builder, $point)
-  {
-    $insertionPoint = $wrapper->findChild($point);
-    if(empty($insertionPoint))
-    {
-      $params = array('slot' => $point);
-      if($wrapper !== $this)
-      {
-        $params['parent_wrap_tag_file'] = $wrapper->getTemplateFile();
-        $params['parent_wrap_tag_line'] = $wrapper->getTemplateLine();
-      }
-
-      $this->raise('Wrap slot not found', $params);
-    }
-
-    $tree_builder->pushCursor($insertionPoint, $this->location);
-  }
-  
-  function generate($code)
-  {
-    if(!$this->is_dynamic)
-      parent :: generate($code);
-  }
-
-  function generateNow($code)
-  {
-    parent :: generate($code); 
-  }
-}
-

Copied: 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroIncludeTagBCTest.class.php (from rev 6789, 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroIncludeTagTest.class.php)
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroIncludeTagBCTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroIncludeTagBCTest.class.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -0,0 +1,170 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+class lmbMacroTagIncludeTest extends lmbBaseMacroTest
+{
+  function testSimpleStaticInclude()
+  {
+    $bar = '<body>{{include file="foo.html"/}}</body>';
+    $foo = '<p>Hello, Bob</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+
+  function testNestedStaticInclude()
+  {
+    $bar = '<body>{{include file="foo.html"/}}</body>';
+    $foo = '<p>Hello, {{include file="name.html"/}}</p>';
+    $name = "Bob";
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $name_tpl = $this->_createTemplate($name, 'name.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+
+  function testStaticIncludePassVariables()
+  {
+    $bar = '<body><?php $var2=2;?>{{include file="foo.html" var1="1" var2="$var2"/}}</body>';
+    $foo = '<p>Numbers: <?php echo $var1;?> <?php echo $var2;?></p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Numbers: 1 2</p></body>');
+  }
+
+  function testStaticInlineInclude()
+  {
+    $bar = '<body><?php $var2=2;?>{{include file="foo.html" inline="true"/}}</body>';
+    $foo = '<p>Number: <?php echo $var2;?></p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Number: 2</p></body>');
+  }
+
+  function testStaticIncludeMixLocalAndTemplateVariables()
+  {
+    $bar = '<body><?php $var2=2;?>{{include file="foo.html" var1="1" var2="$var2"/}}</body>';
+    $foo = '<p>Numbers: <?php echo $var1;?> <?php echo $var2;?> <?php echo $this->var3;?></p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $macro->set('var3', 3);
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Numbers: 1 2 3</p></body>');
+  }
+
+  function testDynamicInclude()
+  {
+    $bar = '<body>{{include file="$this->file"/}}</body>';
+    $foo = '<p>Hello!</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('file', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello!</p></body>');
+  }
+
+  function testDynamicIncludePassLocalVars()
+  {
+    $bar = '<body><?php $name = "Fred";?>{{include file="$this->file" name="$name"/}}</body>';
+    $foo = '<p>Hello, <?php echo $name;?>!</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('file', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Fred!</p></body>');
+  }
+
+  function testDynamicIncludeMixLocalAndTemplateVars()
+  {
+    $bar = '<body><?php $name = "Fred";?>{{include file="$this->file" name="$name"/}}</body>';
+    $foo = '<p>Hello, <?php echo $name . " " . $this->lastname;?>!</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('file', 'foo.html');
+    $macro->set('lastname', 'Atkins');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Fred Atkins!</p></body>');
+  }
+
+  function testStaticIncludeWithChildIntoTagsAndVariables()
+  {
+    $bar = '<body><?php $var2=2;?>'.
+           '{{include file="foo.html" var1="1" var2="$var2"}}'.
+           '{{include:into slot="slot1"}}<b><?php echo $varA;?></b>{{/include:into}}'.
+           '{{include:into slot="slot2"}}<u><?php echo $varB;?></u>{{/include:into}}'.
+           '{{/include}}'.
+           '</body>';
+    $foo = '<p>Numbers: {{slot id="slot1" varA="$var1"/}} {{slot id="slot2" varB="$var2"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Numbers: <b>1</b> <u>2</u></p></body>');
+  }
+
+  function testDynamicIncludeWithChildIntoTagsAndVariables()
+  {
+    $bar = '<body><?php $var2=2;?>'.
+           '{{include file="$#included" var1="1" var2="$var2"}}'.
+           '{{include:into slot="slot1"}}<b><?php echo $varA;?></b>{{/include:into}}'.
+           '{{include:into slot="slot2"}}<u><?php echo $varB;?></u>{{/include:into}}'.
+           '{{/include}}'.
+           '</body>';
+    $foo = '<p>Numbers: {{slot id="slot1" varA="$var1"/}} {{slot id="slot2" varB="$var2"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('included', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Numbers: <b>1</b> <u>2</u></p></body>');
+  }
+}
+

Deleted: 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroIncludeTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroIncludeTagTest.class.php	2008-02-11 14:54:11 UTC (rev 6792)
+++ 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroIncludeTagTest.class.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -1,170 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-class lmbMacroTagIncludeTest extends lmbBaseMacroTest
-{
-  function testSimpleStaticInclude()
-  {
-    $bar = '<body>{{include file="foo.html"/}}</body>';
-    $foo = '<p>Hello, Bob</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
-  }
-
-  function testNestedStaticInclude()
-  {
-    $bar = '<body>{{include file="foo.html"/}}</body>';
-    $foo = '<p>Hello, {{include file="name.html"/}}</p>';
-    $name = "Bob";
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-    $name_tpl = $this->_createTemplate($name, 'name.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
-  }
-
-  function testStaticIncludePassVariables()
-  {
-    $bar = '<body><?php $var2=2;?>{{include file="foo.html" var1="1" var2="$var2"/}}</body>';
-    $foo = '<p>Numbers: <?php echo $var1;?> <?php echo $var2;?></p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Numbers: 1 2</p></body>');
-  }
-
-  function testStaticInlineInclude()
-  {
-    $bar = '<body><?php $var2=2;?>{{include file="foo.html" inline="true"/}}</body>';
-    $foo = '<p>Number: <?php echo $var2;?></p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Number: 2</p></body>');
-  }
-
-  function testStaticIncludeMixLocalAndTemplateVariables()
-  {
-    $bar = '<body><?php $var2=2;?>{{include file="foo.html" var1="1" var2="$var2"/}}</body>';
-    $foo = '<p>Numbers: <?php echo $var1;?> <?php echo $var2;?> <?php echo $this->var3;?></p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $macro->set('var3', 3);
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Numbers: 1 2 3</p></body>');
-  }
-
-  function testDynamicInclude()
-  {
-    $bar = '<body>{{include file="$this->file"/}}</body>';
-    $foo = '<p>Hello!</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('file', 'foo.html');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Hello!</p></body>');
-  }
-
-  function testDynamicIncludePassLocalVars()
-  {
-    $bar = '<body><?php $name = "Fred";?>{{include file="$this->file" name="$name"/}}</body>';
-    $foo = '<p>Hello, <?php echo $name;?>!</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('file', 'foo.html');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Hello, Fred!</p></body>');
-  }
-
-  function testDynamicIncludeMixLocalAndTemplateVars()
-  {
-    $bar = '<body><?php $name = "Fred";?>{{include file="$this->file" name="$name"/}}</body>';
-    $foo = '<p>Hello, <?php echo $name . " " . $this->lastname;?>!</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('file', 'foo.html');
-    $macro->set('lastname', 'Atkins');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Hello, Fred Atkins!</p></body>');
-  }
-
-  function testStaticIncludeWithChildIntoTagsAndVariables()
-  {
-    $bar = '<body><?php $var2=2;?>'.
-           '{{include file="foo.html" var1="1" var2="$var2"}}'.
-           '{{include:into slot="slot1"}}<b><?php echo $varA;?></b>{{/include:into}}'.
-           '{{include:into slot="slot2"}}<u><?php echo $varB;?></u>{{/include:into}}'.
-           '{{/include}}'.
-           '</body>';
-    $foo = '<p>Numbers: {{slot id="slot1" varA="$var1"/}} {{slot id="slot2" varB="$var2"/}}</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Numbers: <b>1</b> <u>2</u></p></body>');
-  }
-
-  function testDynamicIncludeWithChildIntoTagsAndVariables()
-  {
-    $bar = '<body><?php $var2=2;?>'.
-           '{{include file="$#included" var1="1" var2="$var2"}}'.
-           '{{include:into slot="slot1"}}<b><?php echo $varA;?></b>{{/include:into}}'.
-           '{{include:into slot="slot2"}}<u><?php echo $varB;?></u>{{/include:into}}'.
-           '{{/include}}'.
-           '</body>';
-    $foo = '<p>Numbers: {{slot id="slot1" varA="$var1"/}} {{slot id="slot2" varB="$var2"/}}</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('included', 'foo.html');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Numbers: <b>1</b> <u>2</u></p></body>');
-  }
-}
-

Added: 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroInsertTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroInsertTagTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroInsertTagTest.class.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -0,0 +1,447 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+class lmbMacroInsertTagTest extends lmbBaseMacroTest
+{
+  function testSimpleStaticWrap()
+  {
+    $bar = '{{insert into="slot1" file="foo.html"}}Bob{{/insert}}';
+    $foo = '<p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testStaticWrapWithVariables()
+  {
+    $bar = '{{insert into="slot1" file="foo.html"}}<?php echo $this->bob?>{{/insert}}';
+    $foo = '<p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('bob', 'Bob');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testNestedStaticWrap()
+  {
+    $bar = '{{insert into="slot1" file="foo.html"}}<?php echo $this->bob?>{{/insert}}';
+    $foo = '{{insert into="slot2" file="zoo.html"}}<p>Hello, {{slot id="slot1"/}}</p>{{/insert}}';
+    $zoo = '<body>{{slot id="slot2"/}}</body>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $zoo_tpl = $this->_createTemplate($zoo, 'zoo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('bob', 'Bob');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+  
+  function testSimpleStaticIntoRoot()
+  {
+    $included = '{{insert:into slot="slot1"}}Bob{{/insert:into}}';
+    $main = '<p>Hello, {{slot id="slot1"/}}</p>{{insert file="included.html"/}}';
+
+    $included_tpl = $this->_createTemplate($included, 'included.html');
+    $main_tpl = $this->_createTemplate($main, 'main.html');
+
+    $macro = $this->_createMacro($main_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testMultiStaticWrap()
+  {
+    $bar = '{{insert file="foo.html"}}'.
+           '{{insert:into slot="slot1"}}Bob{{/insert:into}}'.
+           '{{insert:into slot="slot2"}}Thorton{{/insert:into}}'.
+           '{{/insert}}';
+    $foo = '<p>Hello, {{slot id="slot2"/}} {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Thorton Bob</p>');
+  }
+
+  function testSimpleDynamicWrap()
+  {
+    $bar = '{{insert into="slot1" file="$this->layout"}}Bob{{/insert}}';
+    $foo = '<p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testMultiDynamicWrap()
+  {
+    $bar = '{{insert file="$this->layout"}}'.
+           '{{insert:into slot="slot1"}}Bob{{/insert:into}}'.
+           '{{insert:into slot="slot2"}}Thorton{{/insert:into}}'.
+           '{{/insert}}';
+    $foo = '<p>Hello, {{slot id="slot2"/}} {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Thorton Bob</p>');
+  }
+
+  function testMixStaticAndDynamicWrap()
+  {
+    $bar = '{{insert into="slot1" file="$this->layout"}}<?php echo $this->bob?>{{/insert}}';
+    $foo = '{{insert into="slot2" file="zoo.html"}}<p>Hello, {{slot id="slot1"/}}</p>{{/insert}}';
+    $zoo = '<body>{{slot id="slot2"/}}</body>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $zoo_tpl = $this->_createTemplate($zoo, 'zoo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+    $macro->set('bob', 'Bob');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+
+  function testNestedDynamicWrap()
+  {
+    $bar = '{{insert into="slot1" file="$this->layout1"}}<?php echo $this->bob?>{{/insert}}';
+    $foo = '{{insert into="slot2" file="$this->layout2"}}<p>Hello, {{slot id="slot1"/}}</p>{{/insert}}';
+    $zoo = '<body>{{slot id="slot2"/}}</body>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $zoo_tpl = $this->_createTemplate($zoo, 'zoo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout1', 'foo.html');
+    $macro->set('layout2', 'zoo.html');
+    $macro->set('bob', 'Bob');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+
+  function testStaticallyWrappedChildAccessesParentData()
+  {
+    $bar = '{{insert into="slot1" file="foo.html"}}<?php echo $this->bob?>{{/insert}}';
+    $foo = '<?php $this->bob = "Bob";?><p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testDynamicallyWrappedChildAccessesParentData()
+  {
+    $bar = '{{insert file="$this->layout" into="slot1"}}<?php echo $this->bob?>{{/insert}}';
+    $foo = '<?php $this->bob = "Bob";?><p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testStaticallyWrappedChildLocalVarsAreIsolated()
+  {
+    $bar = '{{insert file="foo.html" into="slot1"}}<?php $foo = "Todd";?>{{/insert}}';
+    $foo = '<?php $foo = "Bob";?>{{slot id="slot1"/}}<?php echo $foo;?>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, 'Bob');
+  }
+
+  function testDynamicallyWrappedChildLocalVarsAreIsolated()
+  {
+    $bar = '{{insert file="$this->layout" into="slot1"}}<?php $foo = "Todd";?>{{/insert}}';
+    $foo = '<?php $foo = "Bob";?>{{slot id="slot1"/}}<?php echo $foo;?>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, 'Bob');
+  }
+  
+  function testMultiStaticWrapFromIncludedFile()
+  {
+    $child = '{{into slot="slot1"}}Bob{{/into}}{{into slot="slot2"}}Thorton{{/into}}';
+    $main = '{{insert file="base.html"}}{{insert file="child.html"/}}{{/insert}}';
+    $base = '<p>Hello, {{slot id="slot2"/}} {{slot id="slot1"/}}</p>';
+
+    $child_tpl = $this->_createTemplate($child, 'child.html');
+    $base_tpl = $this->_createTemplate($base, 'base.html');
+    $main_tpl = $this->_createTemplate($main, 'main.html');
+
+    $macro = $this->_createMacro($main_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Thorton Bob</p>');
+  }
+
+  function testPassVariablesIntoLocalContextOfSlotTag()
+  {
+    $bar = '{{insert file="foo.html" into="slot1"}}<?php echo $foo;?>{{/insert}}';
+    $foo = '<?php $foo = "Bob";?>{{slot id="slot1" foo="$foo"/}}';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, 'Bob');
+  }
+
+  function testSlotWithInlineAttributeDoesNotCreateAMethodAround()
+  {
+    $bar = '{{insert file="foo.html" into="slot1"}}<?php $foo = "Tedd";?>{{/insert}}';
+    $foo = '<?php $foo = "Bob";?>{{slot id="slot1" inline="true"/}}<?php echo $foo;?>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, 'Tedd');
+  }
+
+  function testSimpleStaticInclude()
+  {
+    $bar = '<body>{{insert file="foo.html"/}}</body>';
+    $foo = '<p>Hello, Bob</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+
+  function testNestedStaticInclude()
+  {
+    $bar = '<body>{{insert file="foo.html"/}}</body>';
+    $foo = '<p>Hello, {{insert file="name.html"/}}</p>';
+    $name = "Bob";
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $name_tpl = $this->_createTemplate($name, 'name.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+
+  function testStaticIncludePassVariables()
+  {
+    $bar = '<body><?php $var2=2;?>{{insert file="foo.html" var1="1" var2="$var2"/}}</body>';
+    $foo = '<p>Numbers: <?php echo $var1;?> <?php echo $var2;?></p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Numbers: 1 2</p></body>');
+  }
+
+  function testStaticInlineInclude()
+  {
+    $bar = '<body><?php $var2=2;?>{{insert file="foo.html" inline="true"/}}</body>';
+    $foo = '<p>Number: <?php echo $var2;?></p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Number: 2</p></body>');
+  }
+
+  function testStaticIncludeMixLocalAndTemplateVariables()
+  {
+    $bar = '<body><?php $var2=2;?>{{insert file="foo.html" var1="1" var2="$var2"/}}</body>';
+    $foo = '<p>Numbers: <?php echo $var1;?> <?php echo $var2;?> <?php echo $this->var3;?></p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $macro->set('var3', 3);
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Numbers: 1 2 3</p></body>');
+  }
+
+  function testDynamicInclude()
+  {
+    $bar = '<body>{{insert file="$this->file"/}}</body>';
+    $foo = '<p>Hello!</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('file', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello!</p></body>');
+  }
+
+  function testDynamicIncludePassLocalVars()
+  {
+    $bar = '<body><?php $name = "Fred";?>{{insert file="$this->file" name="$name"/}}</body>';
+    $foo = '<p>Hello, <?php echo $name;?>!</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('file', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Fred!</p></body>');
+  }
+
+  function testDynamicIncludeMixLocalAndTemplateVars()
+  {
+    $bar = '<body><?php $name = "Fred";?>{{insert file="$this->file" name="$name"/}}</body>';
+    $foo = '<p>Hello, <?php echo $name . " " . $this->lastname;?>!</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('file', 'foo.html');
+    $macro->set('lastname', 'Atkins');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Fred Atkins!</p></body>');
+  }
+
+  function testStaticIncludeWithChildIntoTagsAndVariables()
+  {
+    $bar = '<body><?php $var2=2;?>'.
+           '{{insert file="foo.html" var1="1" var2="$var2"}}'.
+           '{{insert:into slot="slot1"}}<b><?php echo $varA;?></b>{{/insert:into}}'.
+           '{{insert:into slot="slot2"}}<u><?php echo $varB;?></u>{{/insert:into}}'.
+           '{{/insert}}'.
+           '</body>';
+    $foo = '<p>Numbers: {{slot id="slot1" varA="$var1"/}} {{slot id="slot2" varB="$var2"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Numbers: <b>1</b> <u>2</u></p></body>');
+  }
+
+  function testDynamicIncludeWithChildIntoTagsAndVariables()
+  {
+    $bar = '<body><?php $var2=2;?>'.
+           '{{insert file="$#included" var1="1" var2="$var2"}}'.
+           '{{insert:into slot="slot1"}}<b><?php echo $varA;?></b>{{/insert:into}}'.
+           '{{insert:into slot="slot2"}}<u><?php echo $varB;?></u>{{/insert:into}}'.
+           '{{/insert}}'.
+           '</body>';
+    $foo = '<p>Numbers: {{slot id="slot1" varA="$var1"/}} {{slot id="slot2" varB="$var2"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('included', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Numbers: <b>1</b> <u>2</u></p></body>');
+  }
+
+  function testMixDynamicWrapWithStaticInsertWithChildIntoTags()
+  {
+    $layout = '<body>Main: {{slot id="slot_main"/}} Extra: {{slot id="slot_extra"/}}</body>';
+    
+    $bar = '{{insert file="$#layout"}}'.
+           '{{insert:into slot="slot_main"}}'.
+             '<?php $var2 = 2; ?>'.
+             '{{insert file="foo.html" var1="1" var2="$var2"}}'.
+               '{{insert:into slot="slot1"}}<b><?php echo $varA;?></b>{{/insert:into}}'.
+               '{{insert:into slot="slot2"}}<u><?php echo $varB;?></u>{{/insert:into}}'.
+             '{{/insert}}'.
+           '{{/insert:into}}'.
+           '{{/insert}}';
+           
+    $foo = '<p>Numbers: {{slot id="slot1" varA="$var1"/}} {{slot id="slot2" varB="$var2"/}}</p> '.
+           '{{insert:into slot="slot_extra"}}Wow!{{/insert:into}}'; // !!!Note this wrap:into tag
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $layout_tpl = $this->_createTemplate($layout, 'layout.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'layout.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body>Main: <p>Numbers: <b>1</b> <u>2</u></p>  Extra: Wow!</body>');
+  }
+}
+

Copied: 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroWrapTagBCTest.class.php (from rev 6789, 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroWrapTagTest.class.php)
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroWrapTagBCTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroWrapTagBCTest.class.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -0,0 +1,282 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+class lmbMacroWrapTagTest extends lmbBaseMacroTest
+{
+  function testSimpleStaticWrap()
+  {
+    $bar = '{{wrap with="foo.html" into="slot1"}}Bob{{/wrap}}';
+    $foo = '<p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testStaticWrapWithVariables()
+  {
+    $bar = '{{wrap with="foo.html" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
+    $foo = '<p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('bob', 'Bob');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testNestedStaticWrap()
+  {
+    $bar = '{{wrap with="foo.html" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
+    $foo = '{{wrap with="zoo.html" into="slot2"}}<p>Hello, {{slot id="slot1"/}}</p>{{/wrap}}';
+    $zoo = '<body>{{slot id="slot2"/}}</body>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $zoo_tpl = $this->_createTemplate($zoo, 'zoo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('bob', 'Bob');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+  
+  function testSimpleStaticIntoRoot()
+  {
+    $included = '{{into slot="slot1"}}Bob{{/into}}';
+    $main = '<p>Hello, {{slot id="slot1"/}}</p>{{include file="included.html"/}}';
+
+    $included_tpl = $this->_createTemplate($included, 'included.html');
+    $main_tpl = $this->_createTemplate($main, 'main.html');
+
+    $macro = $this->_createMacro($main_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testMultiStaticWrap()
+  {
+    $bar = '{{wrap with="foo.html"}}{{into slot="slot1"}}Bob{{/into}}{{into slot="slot2"}}Thorton{{/into}}{{/wrap}}';
+    $foo = '<p>Hello, {{slot id="slot2"/}} {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Thorton Bob</p>');
+  }
+
+  function testSimpleDynamicWrap()
+  {
+    $bar = '{{wrap with="$this->layout" into="slot1"}}Bob{{/wrap}}';
+    $foo = '<p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testMultiDynamicWrap()
+  {
+    $bar = '{{wrap with="$this->layout"}}{{into slot="slot1"}}Bob{{/into}}{{into slot="slot2"}}Thorton{{/into}}{{/wrap}}';
+    $foo = '<p>Hello, {{slot id="slot2"/}} {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Thorton Bob</p>');
+  }
+
+  function testMixStaticAndDynamicWrap()
+  {
+    $bar = '{{wrap with="$this->layout" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
+    $foo = '{{wrap with="zoo.html" into="slot2"}}<p>Hello, {{slot id="slot1"/}}</p>{{/wrap}}';
+    $zoo = '<body>{{slot id="slot2"/}}</body>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $zoo_tpl = $this->_createTemplate($zoo, 'zoo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+    $macro->set('bob', 'Bob');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+
+  function testNestedDynamicWrap()
+  {
+    $bar = '{{wrap with="$this->layout1" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
+    $foo = '{{wrap with="$this->layout2" into="slot2"}}<p>Hello, {{slot id="slot1"/}}</p>{{/wrap}}';
+    $zoo = '<body>{{slot id="slot2"/}}</body>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $zoo_tpl = $this->_createTemplate($zoo, 'zoo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout1', 'foo.html');
+    $macro->set('layout2', 'zoo.html');
+    $macro->set('bob', 'Bob');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
+  }
+
+  function testStaticallyWrappedChildAccessesParentData()
+  {
+    $bar = '{{wrap with="foo.html" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
+    $foo = '<?php $this->bob = "Bob";?><p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testDynamicallyWrappedChildAccessesParentData()
+  {
+    $bar = '{{wrap with="$this->layout" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
+    $foo = '<?php $this->bob = "Bob";?><p>Hello, {{slot id="slot1"/}}</p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Bob</p>');
+  }
+
+  function testStaticallyWrappedChildLocalVarsAreIsolated()
+  {
+    $bar = '{{wrap with="foo.html" into="slot1"}}<?php $foo = "Todd";?>{{/wrap}}';
+    $foo = '<?php $foo = "Bob";?>{{slot id="slot1"/}}<?php echo $foo;?>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, 'Bob');
+  }
+
+  function testDynamicallyWrappedChildLocalVarsAreIsolated()
+  {
+    $bar = '{{wrap with="$this->layout" into="slot1"}}<?php $foo = "Todd";?>{{/wrap}}';
+    $foo = '<?php $foo = "Bob";?>{{slot id="slot1"/}}<?php echo $foo;?>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'foo.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, 'Bob');
+  }
+  
+  function testMultiStaticWrapFromIncludedFile()
+  {
+    $child = '{{into slot="slot1"}}Bob{{/into}}{{into slot="slot2"}}Thorton{{/into}}';
+    $main = '{{wrap with="base.html"}}{{include file="child.html"/}}{{/wrap}}';
+    $base = '<p>Hello, {{slot id="slot2"/}} {{slot id="slot1"/}}</p>';
+
+    $child_tpl = $this->_createTemplate($child, 'child.html');
+    $base_tpl = $this->_createTemplate($base, 'base.html');
+    $main_tpl = $this->_createTemplate($main, 'main.html');
+
+    $macro = $this->_createMacro($main_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<p>Hello, Thorton Bob</p>');
+  }
+
+  function testPassVariablesIntoLocalContextOfSlotTag()
+  {
+    $bar = '{{wrap with="foo.html" into="slot1"}}<?php echo $foo;?>{{/wrap}}';
+    $foo = '<?php $foo = "Bob";?>{{slot id="slot1" foo="$foo"/}}';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, 'Bob');
+  }
+
+  function testSlotWithInlineAttributeDoesNotCreateAMethodAround()
+  {
+    $bar = '{{wrap with="foo.html" into="slot1"}}<?php $foo = "Tedd";?>{{/wrap}}';
+    $foo = '<?php $foo = "Bob";?>{{slot id="slot1" inline="true"/}}<?php echo $foo;?>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+
+    $out = $macro->render();
+    $this->assertEqual($out, 'Tedd');
+  }
+
+  function testMixDynamicWrapWithStaticIncludeWithChildIntoTags()
+  {
+    $layout = '<body>Main: {{slot id="slot_main"/}} Extra: {{slot id="slot_extra"/}}</body>';
+    
+    $bar = '{{wrap with="$#layout"}}'.
+           '{{wrap:into slot="slot_main"}}<?php $var2=2;?>'.
+             '{{include file="foo.html" var1="1" var2="$var2"}}'.
+               '{{include:into slot="slot1"}}<b><?php echo $varA;?></b>{{/include:into}}'.
+               '{{include:into slot="slot2"}}<u><?php echo $varB;?></u>{{/include:into}}'.
+             '{{/include}}'.
+           '{{/wrap:into}}'.
+           '{{/wrap}}';
+           
+    $foo = '<p>Numbers: {{slot id="slot1" varA="$var1"/}} {{slot id="slot2" varB="$var2"/}}</p> '.
+           '{{wrap:into slot="slot_extra"}}Wow!{{/wrap:into}}'; // !!!Note this wrap:into tag
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+    $layout_tpl = $this->_createTemplate($layout, 'layout.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('layout', 'layout.html');
+
+    $out = $macro->render();
+    $this->assertEqual($out, '<body>Main: <p>Numbers: <b>1</b> <u>2</u></p>  Extra: Wow!</body>');
+  }
+}
+

Deleted: 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroWrapTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroWrapTagTest.class.php	2008-02-11 14:54:11 UTC (rev 6792)
+++ 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroWrapTagTest.class.php	2008-02-11 15:24:56 UTC (rev 6793)
@@ -1,301 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-class lmbMacroWrapTagTest extends lmbBaseMacroTest
-{
-  function testThrowExceptionIfWrapTagForIntoNotFound()
-  {
-    $bar = '{{into slot="slot1"}}Bob{{/into}}';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-
-    try
-    {
-      $macro = $this->_createMacro($bar_tpl);
-      $macro->render();
-      $this->assertTrue(false);
-    }
-    catch(lmbMacroException $e)
-    {
-      $this->assertTrue(true);
-    }
-  }
-  
-  function testSimpleStaticWrap()
-  {
-    $bar = '{{wrap with="foo.html" into="slot1"}}Bob{{/wrap}}';
-    $foo = '<p>Hello, {{slot id="slot1"/}}</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<p>Hello, Bob</p>');
-  }
-
-  function testStaticWrapWithVariables()
-  {
-    $bar = '{{wrap with="foo.html" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
-    $foo = '<p>Hello, {{slot id="slot1"/}}</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('bob', 'Bob');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<p>Hello, Bob</p>');
-  }
-
-  function testNestedStaticWrap()
-  {
-    $bar = '{{wrap with="foo.html" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
-    $foo = '{{wrap with="zoo.html" into="slot2"}}<p>Hello, {{slot id="slot1"/}}</p>{{/wrap}}';
-    $zoo = '<body>{{slot id="slot2"/}}</body>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-    $zoo_tpl = $this->_createTemplate($zoo, 'zoo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('bob', 'Bob');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
-  }
-  
-  function testSimpleStaticIntoRoot()
-  {
-    $included = '{{into slot="slot1"}}Bob{{/into}}';
-    $main = '<p>Hello, {{slot id="slot1"/}}</p>{{include file="included.html"/}}';
-
-    $included_tpl = $this->_createTemplate($included, 'included.html');
-    $main_tpl = $this->_createTemplate($main, 'main.html');
-
-    $macro = $this->_createMacro($main_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<p>Hello, Bob</p>');
-  }
-
-  function testMultiStaticWrap()
-  {
-    $bar = '{{wrap with="foo.html"}}{{into slot="slot1"}}Bob{{/into}}{{into slot="slot2"}}Thorton{{/into}}{{/wrap}}';
-    $foo = '<p>Hello, {{slot id="slot2"/}} {{slot id="slot1"/}}</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<p>Hello, Thorton Bob</p>');
-  }
-
-  function testSimpleDynamicWrap()
-  {
-    $bar = '{{wrap with="$this->layout" into="slot1"}}Bob{{/wrap}}';
-    $foo = '<p>Hello, {{slot id="slot1"/}}</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('layout', 'foo.html');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<p>Hello, Bob</p>');
-  }
-
-  function testMultiDynamicWrap()
-  {
-    $bar = '{{wrap with="$this->layout"}}{{into slot="slot1"}}Bob{{/into}}{{into slot="slot2"}}Thorton{{/into}}{{/wrap}}';
-    $foo = '<p>Hello, {{slot id="slot2"/}} {{slot id="slot1"/}}</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('layout', 'foo.html');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<p>Hello, Thorton Bob</p>');
-  }
-
-  function testMixStaticAndDynamicWrap()
-  {
-    $bar = '{{wrap with="$this->layout" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
-    $foo = '{{wrap with="zoo.html" into="slot2"}}<p>Hello, {{slot id="slot1"/}}</p>{{/wrap}}';
-    $zoo = '<body>{{slot id="slot2"/}}</body>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-    $zoo_tpl = $this->_createTemplate($zoo, 'zoo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('layout', 'foo.html');
-    $macro->set('bob', 'Bob');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
-  }
-
-  function testNestedDynamicWrap()
-  {
-    $bar = '{{wrap with="$this->layout1" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
-    $foo = '{{wrap with="$this->layout2" into="slot2"}}<p>Hello, {{slot id="slot1"/}}</p>{{/wrap}}';
-    $zoo = '<body>{{slot id="slot2"/}}</body>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-    $zoo_tpl = $this->_createTemplate($zoo, 'zoo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('layout1', 'foo.html');
-    $macro->set('layout2', 'zoo.html');
-    $macro->set('bob', 'Bob');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
-  }
-
-  function testStaticallyWrappedChildAccessesParentData()
-  {
-    $bar = '{{wrap with="foo.html" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
-    $foo = '<?php $this->bob = "Bob";?><p>Hello, {{slot id="slot1"/}}</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<p>Hello, Bob</p>');
-  }
-
-  function testDynamicallyWrappedChildAccessesParentData()
-  {
-    $bar = '{{wrap with="$this->layout" into="slot1"}}<?php echo $this->bob?>{{/wrap}}';
-    $foo = '<?php $this->bob = "Bob";?><p>Hello, {{slot id="slot1"/}}</p>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('layout', 'foo.html');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<p>Hello, Bob</p>');
-  }
-
-  function testStaticallyWrappedChildLocalVarsAreIsolated()
-  {
-    $bar = '{{wrap with="foo.html" into="slot1"}}<?php $foo = "Todd";?>{{/wrap}}';
-    $foo = '<?php $foo = "Bob";?>{{slot id="slot1"/}}<?php echo $foo;?>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, 'Bob');
-  }
-
-  function testDynamicallyWrappedChildLocalVarsAreIsolated()
-  {
-    $bar = '{{wrap with="$this->layout" into="slot1"}}<?php $foo = "Todd";?>{{/wrap}}';
-    $foo = '<?php $foo = "Bob";?>{{slot id="slot1"/}}<?php echo $foo;?>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('layout', 'foo.html');
-
-    $out = $macro->render();
-    $this->assertEqual($out, 'Bob');
-  }
-  
-  function testMultiStaticWrapFromIncludedFile()
-  {
-    $child = '{{into slot="slot1"}}Bob{{/into}}{{into slot="slot2"}}Thorton{{/into}}';
-    $main = '{{wrap with="base.html"}}{{include file="child.html"/}}{{/wrap}}';
-    $base = '<p>Hello, {{slot id="slot2"/}} {{slot id="slot1"/}}</p>';
-
-    $child_tpl = $this->_createTemplate($child, 'child.html');
-    $base_tpl = $this->_createTemplate($base, 'base.html');
-    $main_tpl = $this->_createTemplate($main, 'main.html');
-
-    $macro = $this->_createMacro($main_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<p>Hello, Thorton Bob</p>');
-  }
-
-  function testPassVariablesIntoLocalContextOfSlotTag()
-  {
-    $bar = '{{wrap with="foo.html" into="slot1"}}<?php echo $foo;?>{{/wrap}}';
-    $foo = '<?php $foo = "Bob";?>{{slot id="slot1" foo="$foo"/}}';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, 'Bob');
-  }
-
-  function testSlotWithInlineAttributeDoesNotCreateAMethodAround()
-  {
-    $bar = '{{wrap with="foo.html" into="slot1"}}<?php $foo = "Tedd";?>{{/wrap}}';
-    $foo = '<?php $foo = "Bob";?>{{slot id="slot1" inline="true"/}}<?php echo $foo;?>';
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-
-    $out = $macro->render();
-    $this->assertEqual($out, 'Tedd');
-  }
-
-  function testMixDynamicWrapWithStaticIncludeWithChildIntoTags()
-  {
-    $layout = '<body>Main: {{slot id="slot_main"/}} Extra: {{slot id="slot_extra"/}}</body>';
-    
-    $bar = '{{wrap with="$#layout"}}'.
-           '{{wrap:into slot="slot_main"}}<?php $var2=2;?>'.
-             '{{include file="foo.html" var1="1" var2="$var2"}}'.
-               '{{include:into slot="slot1"}}<b><?php echo $varA;?></b>{{/include:into}}'.
-               '{{include:into slot="slot2"}}<u><?php echo $varB;?></u>{{/include:into}}'.
-             '{{/include}}'.
-           '{{/wrap:into}}'.
-           '{{/wrap}}';
-           
-    $foo = '<p>Numbers: {{slot id="slot1" varA="$var1"/}} {{slot id="slot2" varB="$var2"/}}</p> '.
-           '{{wrap:into slot="slot_extra"}}Wow!{{/wrap:into}}'; // !!!Note this wrap:into tag
-
-    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
-    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
-    $layout_tpl = $this->_createTemplate($layout, 'layout.html');
-
-    $macro = $this->_createMacro($bar_tpl);
-    $macro->set('layout', 'layout.html');
-
-    $out = $macro->render();
-    $this->assertEqual($out, '<body>Main: <p>Numbers: <b>1</b> <u>2</u></p>  Extra: Wow!</body>');
-  }
-    
-}
-



More information about the limb-svn mailing list