 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
asmodeus Smarty n00b
Joined: 23 Mar 2010 Posts: 1
|
Posted: Tue Mar 23, 2010 5:12 pm Post subject: PHPTAL styled macros? |
|
|
Hi guys,
I am in serious need of assistence here. I have just started a new web development job and the new boss is a big fan of the PHPTAL template parser. Personally I dont aggree and really want to convince him that we should be using smarty. His main argument for PHPTAL so far has been its use of macros (which I admit is kind of nifty), but if can replicate the same functionality in smarty then I can probably convince him. This is where I need some help...
PHPTal allows you to do things like...
| Code: | <div metal:define-macro="box" tal:attributes="class class; id id">
<h1><tal:block metal:define-slot="heading"/></h1>
<p><tal:block metal:define-slot="content" /></p>
</div> |
and then use this code later by doing...
| Code: | <tal:block metal:use-macro="box" tal:define="class string:bloxclass; id string:boxid">
<tal:block metal:fill-slot="heading">
Header Hoes Here
</tal:block>
<tal:block metal:fill-slot="content">
<p>This is the body content of the webpage</p>
<img src="image.jpg"/>
<a href="next.html">Click Here To See More</a>
</tal:block>
</tal:block> |
So, what I would like to be able to do is...
| Code: | {define-macro name="box"}
<div class="{$class}" id="{$id}">
<h1>{$heading}</h1>
<p>{$content}</p>
</div>
{/define_macro} |
and use it, something similar to...
| Code: | {use_macro name="box" class="bloxclass" id="boxid"}
{macro_assign name="heading"}
Header Hoes Here
{/macro_assign}
{macro_assign name="content"}
<p>This is the body content of the webpage</p>
<img src="image.jpg"/>
<a href="next.html">Click Here To See More</a>
{/macro_assign}
{/use_macro} |
But I cant quite figure it out...
Can anyone help? |
|
| Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 4185 Location: Hamburg / Germany
|
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|