[limb-svn] r6290 - in 3.x/trunk/limb/macro: src/tags tests/cases/tags
svn at limb-project.com
svn at limb-project.com
Wed Sep 12 01:19:53 MSD 2007
Author: pachanga
Date: 2007-09-12 01:19:53 +0400 (Wed, 12 Sep 2007)
New Revision: 6290
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6290
Added:
3.x/trunk/limb/macro/src/tags/into.tag.php
Modified:
3.x/trunk/limb/macro/src/tags/wrap.tag.php
3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php
Log:
-- first unfortunate take on multi wrap tag version
Added: 3.x/trunk/limb/macro/src/tags/into.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/into.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/into.tag.php 2007-09-11 21:19:53 UTC (rev 6290)
@@ -0,0 +1,26 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+//temporary includes, make it more flexible later
+lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
+lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+lmbMacroTagDictionary :: instance()->register(new lmbMacroTagInfo('into', 'lmbMacroIntoTag'), __FILE__);
+
+/**
+ * class lmbMacroIntoTag.
+ *
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroIntoTag extends lmbMacroTag
+{
+}
+
Modified: 3.x/trunk/limb/macro/src/tags/wrap.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/wrap.tag.php 2007-09-11 20:28:52 UTC (rev 6289)
+++ 3.x/trunk/limb/macro/src/tags/wrap.tag.php 2007-09-11 21:19:53 UTC (rev 6290)
@@ -30,9 +30,29 @@
$file = $this->get('with');
$this->_compileSourceFileName($file, $compiler);
- $this->_makeInsertion($this, $tree_builder);
+
+ if($includes = $this->_collectIncludes())
+ {
+ var_dump($includes);
+ foreach($includes as $include)
+ {
+ $this->_insert($include, $tree_builder, $include->get('slot'));
+ }
+ }
+ else
+ $this->_insert($this, $tree_builder, $this->get('into'));
}
+ protected function _isMultiWrap()
+ {
+ return sizeof($this->_collectIncludes()) !== 0;
+ }
+
+ protected function _collectIncludes()
+ {
+ return $this->findImmediateChildrenByClass('lmbMacroIntoTag');
+ }
+
protected function _compileSourceFileName($file, $compiler)
{
$this->sourcefile = $compiler->getTemplateLocator()->locateSourceTemplate($file);
@@ -43,12 +63,6 @@
$compiler->parseTemplate($file, $this);
}
- protected function _makeInsertion($wrapper, $tree_builder)
- {
- if($insertionId = $this->get('into'))
- $this->_insert($wrapper, $tree_builder, $insertionId);
- }
-
function _insert($wrapper, $tree_builder, $point)
{
$this->_insertOrReplace($wrapper, $tree_builder, $point, $replace = false);
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-11 20:28:52 UTC (rev 6289)
+++ 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php 2007-09-11 21:19:53 UTC (rev 6290)
@@ -7,10 +7,11 @@
* @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
+lmb_require('limb/fs/src/lmbFs.class.php');
lmb_require('limb/macro/src/lmbMacroTemplate.class.php');
lmb_require('limb/macro/src/tags/wrap.tag.php');
lmb_require('limb/macro/src/tags/slot.tag.php');
-lmb_require('limb/fs/src/lmbFs.class.php');
+lmb_require('limb/macro/src/tags/into.tag.php');
class lmbMacroWrapTagTest extends UnitTestCase
{
@@ -66,6 +67,20 @@
$this->assertEqual($out, '<body><p>Hello, Bob</p></body>');
}
+ function testMultiWrap()
+ {
+ $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>');
+ }
+
protected function _createMacro($file)
{
$base_dir = LIMB_VAR_DIR . '/tpl';
More information about the limb-svn
mailing list