[PHPTAL] bug?

Gosi gosi at usk18.de
Wed Mar 19 13:40:45 CET 2008


Hi Kornel,

Kornel Lesinski schrieb:
> On 18 Mar 2008, at 22:32, Gosi wrote:
> 
>> i think there is a bug in PHPTAL.php at the executeMacro() method.
>>
>> the "require_once" at line 338 is missing.
>>
>> else {
>>     // call local macro
>>     require_once $this->getCodePath();
>>     $fun = $this->getFunctionName() . '_' . trim($path);
>>     if (!function_exists($fun)) throw new PHPTAL_Exception(...);
>>     $fun( $this, $this->_context );
>> }
> 
> 
> It's not a bug, it's a feature ;)
> This code fragment is for macros defined in the same file as their
> caller, so there should be no need to load the file again.
> 
> If it doesn't work for you, could you send me an example template that
> exposes the bug?
> 

I need a way to just execute a macro or execute the hole template. So
I'm calling the public executeMacro method. This only works with the
'require_once'.

e.g.:

$this->_phptal->setTemplate($file);

if ($this->_renderMacro) {
	$this->_phptal->prepare();
	echo $this->_phptal->executeMacro($this->_macroName);
} else {
	echo $this->_phptal->execute();
}

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>
    	title
    </title>
  </head>
  <body>
  <tal:block  metal:use-macro="table" />
  <table metal:define-macro="table">
  	<tr>
  		<td style="border: 1px dashed green">
  			<tal:block replace="var1" />
  		</td>
  		<td style="border: 1px dashed red">
			<tal:block replace="var2" />
  		</td>
  		<td style="border: 1px dashed green">
			<tal:block replace="var3" />
  		</td>
  	</tr>
  </table>
  </body>
</html>


regards, gosi



More information about the PHPTAL mailing list