[limb-svn] r6979 - in 3.x/trunk/limb/macro: src/tags/list tests/cases/tags/list
svn at limb-project.com
svn at limb-project.com
Sat May 3 16:36:52 MSD 2008
Author: pachanga
Date: 2008-05-03 16:36:52 +0400 (Sat, 03 May 2008)
New Revision: 6979
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6979
Modified:
3.x/trunk/limb/macro/src/tags/list/list.tag.php
3.x/trunk/limb/macro/tests/cases/tags/list/lmbMacroListTagTest.class.php
Log:
-- fixing post/pre {{list:item}} condition bug
Modified: 3.x/trunk/limb/macro/src/tags/list/list.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list.tag.php 2008-04-30 14:45:48 UTC (rev 6978)
+++ 3.x/trunk/limb/macro/src/tags/list/list.tag.php 2008-05-03 12:36:52 UTC (rev 6979)
@@ -57,25 +57,25 @@
$found_item_tag = false;
$postponed_nodes = array();
+ //tags before {{list:item}} should be rendered only once when counter is 0
+ $code->writePHP('if(' . $this->counter_var . ' == 0) {');
foreach($this->children as $child)
{
//we want to skip some of {{list:*}} tags, since they are rendered manually
if(!$this->_isOneOfListTags($child))
{
- //tags before {{list:item}} should be rendered only once when counter is 0
if(!$found_item_tag)
{
- $code->writePHP('if(' . $this->counter_var . ' == 0) {');
$child->generate($code);
- $code->writePHP('}');
}
- //otherwise we collect them to display later
+ //collectng postponed nodes to display later
else
$postponed_nodes[] = $child;
}
elseif(is_a($child, 'lmbMacroListItemTag'))
{
$found_item_tag = true;
+ $code->writePHP('}');
$child->generate($code);
}
}
@@ -84,12 +84,10 @@
$code->writePHP('}');
//tags after {{list:item}} should be rendered only if there were any items
+ $code->writePHP('if(' . $this->counter_var . ' > 0) {');
foreach($postponed_nodes as $node)
- {
- $code->writePHP('if(' . $this->counter_var . ' > 0) {');
$node->generate($code);
- $code->writePHP('}');
- }
+ $code->writePHP('}');
$this->_renderEmptyTag($code);
}
Modified: 3.x/trunk/limb/macro/tests/cases/tags/list/lmbMacroListTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/list/lmbMacroListTagTest.class.php 2008-04-30 14:45:48 UTC (rev 6978)
+++ 3.x/trunk/limb/macro/tests/cases/tags/list/lmbMacroListTagTest.class.php 2008-05-03 12:36:52 UTC (rev 6979)
@@ -22,6 +22,19 @@
$this->assertEqual($out, 'Bob Todd ');
}
+ function testGroupVisibilityConditionForPreAndPostListTags()
+ {
+ $list = '{{list using="$#list" as="$item"}}<?if(false){?>Junk1<?}?>{{list:item}}<?=$item?> {{/list:item}}<?if(false){?>Junk2<?}?>{{/list}}';
+
+ $list_tpl = $this->_createTemplate($list, 'list.html');
+
+ $macro = $this->_createMacro($list_tpl);
+ $macro->set('list', array('Bob', 'Todd'));
+
+ $out = $macro->render();
+ $this->assertEqual($out, 'Bob Todd ');
+ }
+
function testListUsingDefaultItem()
{
$list = '{{list using="$#list"}}{{list:item}}<?=$item?> {{/list:item}}{{/list}}';
More information about the limb-svn
mailing list