[limb-svn] r6271 - in 3.x/trunk/limb/macro: src tests/cases/tags
svn at limb-project.com
svn at limb-project.com
Fri Sep 7 12:50:46 MSD 2007
Author: pachanga
Date: 2007-09-07 12:50:46 +0400 (Fri, 07 Sep 2007)
New Revision: 6271
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6271
Modified:
3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php
3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php
Log:
-- adding some more fine grained tests for include tag and fixing bugs
Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php 2007-09-07 08:02:59 UTC (rev 6270)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php 2007-09-07 08:50:46 UTC (rev 6271)
@@ -44,7 +44,7 @@
$compiled_file = $this->locator->locateCompiledTemplate($this->file);
- $class = 'TemplateExecutor' . uniqid();//???
+ $class = 'MacroTemplateExecutor' . uniqid();//???
$compiler = $this->_createCompiler();
$compiler->compile($source_file, $compiled_file, $class, 'render');
Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php 2007-09-07 08:02:59 UTC (rev 6270)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php 2007-09-07 08:50:46 UTC (rev 6271)
@@ -18,7 +18,7 @@
function __construct($vars = array())
{
foreach($vars as $name => $value)
- $this->name = $value;
+ $this->$name = $value;
}
function set($name, $value)
@@ -26,6 +26,12 @@
$this->$name = $value;
}
+ function __get($name)
+ {
+ //we definitely want to supress warnings, make it some sort of a NullObject?
+ return '';
+ }
+
function render(){}
}
Modified: 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php 2007-09-07 08:02:59 UTC (rev 6270)
+++ 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php 2007-09-07 08:50:46 UTC (rev 6271)
@@ -22,6 +22,20 @@
function testSimpleInclude()
{
$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 testNestedInclude()
+ {
+ $bar = '<body><%include file="foo.html"/%></body>';
$foo = '<p>Hello, <%include file="name.html"/%></p>';
$name = "Bob";
@@ -48,7 +62,22 @@
$out = $macro->render();
$this->assertEqual($out, '<body><p>Numbers: 1 2</p></body>');
}
+
+ function testIncludeMixLocalAndTemplateVariables()
+ {
+ $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>');
+ }
+
protected function _createMacro($file)
{
$base_dir = LIMB_VAR_DIR . '/tpl';
More information about the limb-svn
mailing list