I needed to generate several templates all using the same set of data
so I populated a single template and then reset the template before
each execute.
However using setSource() to load a template instead of setTemplate()
does not seem to properly reset the state of the template. I added
the two lines
$this->_prepared = false;
$this->_functionName = null;
from setTemplate() to setSource() to force the reset.
/**
* Set template from file path.
* @param $path string
*/
public function setTemplate($path)
{
$this->_prepared = false;
$this->_functionName = null;
$this->_path = $path;
$this->_source = null;
return $this;
}
/**
* Set template from source.
*
* Should be used only with temporary template sources. Use
setTemplate() whenever possible.
*
* @param $src string The phptal template source.
* @param path string Fake and 'unique' template path.
*/
public function setSource($src, $path=false)
{
if ($path == false)
$path = '<string> '.md5($src);
require_once PHPTAL_DIR.'PHPTAL/StringSource.php';
$this->_source = new PHPTAL_StringSource($src, $path);
$this->_path = $path;
return $this;
}
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal