template framework suggestions

2 views
Skip to first unread message

Ovidiu Alexa

unread,
Aug 30, 2010, 9:41:37 AM8/30/10
to professi...@googlegroups.com
Hi, I've been using Templator() for quite a while.

The fact that it is very simple makes this very fast and easy to work with; for those of you who don't know about this I'll give you an example:

HTML code
<!-- $BeginBlock  row -->

<div>${var_value}</div>
   
<!-- $EndBlock  row -->


php code:

$tpl=new Templator();
$tpl->readTemplateFromFile('the_above_html_file.html');

for($x=0; $x<10; $x++)
    {
    $tpl->setVariable('var_value', $x);
    $tpl->addBlock('row');
    }

and the output:
<div>0</div>
<div>1</div>
<div>2</div>
<div>3</div>
[...]
<div>10</div>


The question is: is there a faster way to code separately from html in such a method? Is there another Templator-like framwork for php? Please tell me what frameworks you use...


Cheers!

Robert Gonzalez

unread,
Aug 30, 2010, 1:22:01 PM8/30/10
to professi...@googlegroups.com
I'm not really a fan of template engines that force you to use another "language" to put your data into the templates (ie Smarty, TemplateLite, phpBB template class, etc). It seems to me that PHP is a template engine in and of itself and there's really no reason to use something else entirely to render your markup.

Something I have used in the past that, to me, is the cleanest way of doing it, is the Savant templating package. This particular package is essentially the view layer used in the Solar Framework by Paul M. Jones. It is clean, fast, and all PHP. If you are planning on separating your views out I'd recommend something like this.

--
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
 
For information or project assistance please visit :
http://www.360psg.com
 
You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professi...@googlegroups.com
To unsubscribe from this group, send email to Professional-P...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Professional-PHP

Ovidiu Alexa

unread,
Aug 30, 2010, 1:31:02 PM8/30/10
to professi...@googlegroups.com
right, thanks. the reason I need to use templates is because I work with a designer that doesn't know much php and also it's faster to fix html code , in comparison with the traditional method, even if you separate the sql from the rendering php it's still a matter of php getting in the way of html. for instance: if you want to make a conditional table in html (a list with different colored rows) you will have to put the basic <?=($x%2==0)?'white_class_bk':'gray_class_bk'?> but in templator you'll only have to put a single variable in html ${bk} and then in php you can make the code to change that var. Seems to me that it does it's job. So thanks for that link, but it actually makes things go backwards for me, I was trying to simplify even more the Tempaltor() method;

Cheers!

Robert Gonzalez

unread,
Aug 30, 2010, 1:34:46 PM8/30/10
to professi...@googlegroups.com
On Mon, Aug 30, 2010 at 10:31 AM, Ovidiu Alexa <ovidiu...@gmail.com> wrote:
for instance: if you want to make a conditional table in html (a list with different colored rows) you will have to put the basic <?=($x%2==0)?'white_class_bk':'gray_class_bk'?> but in templator you'll only have to put a single variable in html ${bk} and then in php you can make the code to change that var. 

Cheers!

You know, you *can* do this in plain old PHP and HTML too. ;) 

Ovidiu Alexa

unread,
Aug 30, 2010, 1:46:13 PM8/30/10
to professi...@googlegroups.com
yeah, my point is that you have much cleaner html code. so this is the main reason that I use templates, I have a designer that is not interested in my code.
Reply all
Reply to author
Forward
0 new messages