diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 46db956..39f3632 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -34,8 +34,4 @@
./src/
-
-
-
-
\ No newline at end of file
diff --git a/src/Fenom/Compiler.php b/src/Fenom/Compiler.php
index 5629c01..84cc0ce 100644
--- a/src/Fenom/Compiler.php
+++ b/src/Fenom/Compiler.php
@@ -39,7 +39,8 @@ class Compiler
if ($name && ($tpl->getStorage()->getOptions() & \Fenom::FORCE_INCLUDE)) {
$inc = $tpl->getStorage()->compile($name, false);
$tpl->addDepend($inc);
- return '$_tpl = (array)$tpl; $tpl->exchangeArray(' . self::toArray($p) . '+$_tpl); ?>' . $inc->getBody() . 'exchangeArray($_tpl); unset($_tpl);';
+ $var = $tpl->tmpVar();
+ return $var.' = (array)$tpl; $tpl->exchangeArray(' . self::toArray($p) . '+'.$var.'); ?>' . $inc->getBody() . 'exchangeArray('.$var.'); unset('.$var.');';
} else {
return '$tpl->getStorage()->getTemplate(' . $cname . ')->display(' . self::toArray($p) . '+(array)$tpl);';
}
@@ -47,7 +48,8 @@ class Compiler
if ($name && ($tpl->getStorage()->getOptions() & \Fenom::FORCE_INCLUDE)) {
$inc = $tpl->getStorage()->compile($name, false);
$tpl->addDepend($inc);
- return '$_tpl = (array)$tpl; ?>' . $inc->getBody() . 'exchangeArray($_tpl); unset($_tpl);';
+ $var = $tpl->tmpVar();
+ return $var.' = (array)$tpl; ?>' . $inc->getBody() . 'exchangeArray('.$var.'); unset('.$var.');';
} else {
return '$tpl->getStorage()->getTemplate(' . $cname . ')->display((array)$tpl);';
}
diff --git a/src/Fenom/Template.php b/src/Fenom/Template.php
index 77947d2..8030371 100644
--- a/src/Fenom/Template.php
+++ b/src/Fenom/Template.php
@@ -99,6 +99,11 @@ class Template extends Render
private $_filters = array();
+ /**
+ * @var int crc32 of the template name
+ */
+ private $_crc = 0;
+
protected static $_tests = array(
'integer' => 'is_int(%s)',
'int' => 'is_int(%s)',
@@ -157,6 +162,7 @@ class Template extends Render
public function load($name, $compile = true)
{
$this->_name = $name;
+ $this->_crc = crc32($this->_name);
if ($provider = strstr($name, ":", true)) {
$this->_scm = $provider;
$this->_base_name = substr($name, strlen($provider) + 1);
@@ -300,7 +306,7 @@ class Template extends Render
*/
public function tmpVar()
{
- return '$t' . ($this->i++);
+ return sprintf('$t%u_%d', $this->_crc, $this->i++);
}
/**