[Petal] METAL with TAL inside

Jean-Michel Hiver jhiver at mkdoc.com
Mon Jun 7 07:29:24 BST 2004


Yuval Kogman wrote:
> Hi,
> 
> In the effort of creating Maypole::View::Petal, I'm breaking my head
> over a transliteration of the orginal template toolkit templates to
> Petal.

Cool :-)


> There is extensive use of macros in the TT code, which I guess is a good
> thing. I attempted to keep the templates pretty much 1:1 where possible,
> but I'm now stuck.
> 
> 
> Here is an example template:
> 
> <span metal:define-macro="display_line">
> 	<span tal:repeat="col classmetadata/colums" tal:omit-tag="string:1">
> 		<td tal:condition="false: equal:col id">
> 			<?if name="equal:col url"?>
> 				<a tal:attr="href item/url" tal:content="item/url"/>
> ...

It which file do you define this macro?


> It gives
> 
> 	<span tal:repeat="col classmetadata/colums" tal:omit-tag="string:1">
> 		<td tal:condition="false: equal:col id">
> 			
> 				<a tal:attr="href item/url" tal:content="item/url"></a>
> 			
> 		</td>
> 	...
> 
> and so on as the output to the browser.

It looks like you have been using the tal: prefix without declaring the 
right namespace.

from 'perldoc Petal':

<html xmlns:tal="http://purl.org/petal/1.0/">
   <body tal:content="bar">Dummy Content</body>
</html>

If you don't declare the Petal namespace, the prefix by default is 
petal:, not tal:


> This is how it's called:
> 
> 	<span metal:use-macro="macros#display_line"/>

This will not work. Petal's implementation of METAL is only partial, and 
you need to read the docs :)

http://search.cpan.org/~jhiver/Petal-2.06/lib/Petal.pm#MORE_INCLUDES:_METAL

http://search.cpan.org/~jhiver/Petal-2.06/lib/Petal.pm#INCLUDES



More information about the Petal mailing list