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

svn at limb-project.com svn at limb-project.com
Sun Sep 16 14:15:05 MSD 2007


Author: pachanga
Date: 2007-09-16 14:15:05 +0400 (Sun, 16 Sep 2007)
New Revision: 6305
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6305

Modified:
   3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php
   3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php
Log:
-- adding support for nested dynamic <%wrap%>

Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php	2007-09-16 09:42:02 UTC (rev 6304)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php	2007-09-16 10:15:05 UTC (rev 6305)
@@ -53,6 +53,7 @@
   function wrapTemplate($file, $slots_handlers)
   {
     $template = new lmbMacroTemplate($file, $this->cache_dir, $this->locator);
+    $template->setVars(get_object_vars($this));//global template vars
     foreach($slots_handlers as $name => $handler)
       $template->set('__slot_handler_' . $name, $handler);
     echo $template->render();

Modified: 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php	2007-09-16 09:42:02 UTC (rev 6304)
+++ 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php	2007-09-16 10:15:05 UTC (rev 6305)
@@ -114,6 +114,25 @@
     $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>');
+  }
+
   protected function _createMacro($file)
   {
     $base_dir = LIMB_VAR_DIR . '/tpl';



More information about the limb-svn mailing list