[limb-svn] r6794 - in 3.x/trunk/limb/macro: src/compiler tests/cases/compiler
svn at limb-project.com
svn at limb-project.com
Tue Feb 12 00:18:58 MSK 2008
Author: pachanga
Date: 2008-02-12 00:18:58 +0300 (Tue, 12 Feb 2008)
New Revision: 6794
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6794
Modified:
3.x/trunk/limb/macro/src/compiler/lmbMacroPreprocessor.class.php
3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateTest.class.php
Log:
-- adding <?xml special case better handling even for situation when short_open_tag = On
Modified: 3.x/trunk/limb/macro/src/compiler/lmbMacroPreprocessor.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/compiler/lmbMacroPreprocessor.class.php 2008-02-11 15:24:56 UTC (rev 6793)
+++ 3.x/trunk/limb/macro/src/compiler/lmbMacroPreprocessor.class.php 2008-02-11 21:18:58 UTC (rev 6794)
@@ -19,7 +19,13 @@
function process(&$contents)
{
$contents = str_replace('<?=', '<?php echo ', $contents);
- $contents = preg_replace('~<\?(?!php|=|xml)~', '<?php ', $contents);
+ $contents = preg_replace_callback('~(<\?xml\s+[^\?]+?\?>)~', array($this, 'xmlSpecialCase'), $contents);
+ $contents = preg_replace('~<\?(?!php|=|xml)~', '<?php ', $contents);
$contents = str_replace('$#', '$this->', $contents);
}
+
+ function xmlSpecialCase($matches)
+ {
+ return '<?php echo "' . str_replace('"', '\"', $matches[1]) . '";?>';
+ }
}
Modified: 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateTest.class.php 2008-02-11 15:24:56 UTC (rev 6793)
+++ 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateTest.class.php 2008-02-11 21:18:58 UTC (rev 6794)
@@ -18,18 +18,27 @@
function testPreprocessor_ProcessPHPShortTags()
{
+ if(ini_get('short_open_tag') == 1)
+ echo __METHOD__ . "() does not check anything, since short tags are ON\n";
+
$view = $this->_createMacroTemplate('Hello, <?echo "Bob";?>');
$this->assertEqual($view->render(), 'Hello, Bob');
}
function testPreprocessor_LeaveXmlTagAsIs()
{
- $view = $this->_createMacroTemplate("<?xml version='1.0' encoding='utf-8'?>");
- $this->assertEqual($view->render(), "<?xml version='1.0' encoding='utf-8'?>");
+ if(ini_get('short_open_tag') == 0)
+ echo __METHOD__ . "() does not check anything, since short tags are OFF\n";
+
+ $view = $this->_createMacroTemplate("<?xml version='1.0' encoding=\"utf-8\"?>");
+ $this->assertEqual($view->render(), "<?xml version='1.0' encoding=\"utf-8\"?>");
}
function testPreprocessor_ProcessPHPShortOutputTags()
{
+ if(ini_get('short_open_tag') == 1)
+ echo __METHOD__ . "() does not check anything, since short tags are ON\n";
+
$view = $this->_createMacroTemplate('Hello, <?=$this->name?>');
$view->set('name', 'Bob');
$this->assertEqual($view->render(), 'Hello, Bob');
@@ -37,7 +46,7 @@
function testPreprocessor_ReplaceGlobalVars()
{
- $view = $this->_createMacroTemplate('Hello, <?=$#name?>');
+ $view = $this->_createMacroTemplate('Hello, <?php echo $#name?>');
$view->set('name', 'Bob');
$this->assertEqual($view->render(), 'Hello, Bob');
}
More information about the limb-svn
mailing list