I am in need of web template engine and I am considering two options. PHPSavant and Smarty.

I am using PHP ver. 5 and PostgreSQL database. PHPSavant supports PHP5 only in beta2 version, so I am affraid of some serious bugs, but at the other hand, as far as I know, Smarty do not support PHP5 at all.

I do not want templates, where HTML and PHP are mixed up together like this:

<ul>
  <?php
    foreach($list as $line) {
      echo '<li>'.$line['text'].'</li>';
    }
  ?>
</ul>

or even worse, when template engine defines its own language:

<ul>
  {foreach from=$list item="line"}
    <li>{$line.text|escape}</li>
  {/foreach}
</ul>

What I want are clean templates in template files and universal code to process them in the other file, like this:
base template (mylist.tpl.php):

<ul>
  {TPL:LINE}
</ul>

line template (mylist_line.tpl.php):

<li>
  {VAL:TEXT}
</li>

code being executed (process_template.php):

<?php
// some PHP script (containing NO HTML tags), which is loading and processing template files, according to arguments supplied
...
?>

Do anybody know PHPSavant and Smarty better than me (had used them) and can tell me which of these two is capable to meet my needs, please?

Recommended Answers

All 5 Replies

I use Smarty because it suits all my needs. I am not worried about incompitble with PHP 5.x. You might want to take a look at patTemplate http://www.php-tools.de/site.php

Mambo CMS -> patTemplate
Hotscripts.com -> Smarty

Hello there,

We use php5 and smarty (2.6.10) and we haven't had any problems whatsoever.

I don't know anything about phpSavant, but we love smarty.

Good luck
bob

I am in need of web template engine and I am considering two options. PHPSavant and Smarty.

I am using PHP ver. 5 and PostgreSQL database. PHPSavant supports PHP5 only in beta2 version, so I am affraid of some serious bugs, but at the other hand, as far as I know, Smarty do not support PHP5 at all.

I do not want templates, where HTML and PHP are mixed up together like this:

<ul>
  <?php
    foreach($list as $line) {
      echo '<li>'.$line['text'].'</li>';
    }
  ?>
</ul>

or even worse, when template engine defines its own language:

<ul>
  {foreach from=$list item="line"}
    <li>{$line.text|escape}</li>
  {/foreach}
</ul>

What I want are clean templates in template files and universal code to process them in the other file, like this:
base template (mylist.tpl.php):

<ul>
  {TPL:LINE}
</ul>

line template (mylist_line.tpl.php):

<li>
  {VAL:TEXT}
</li>

code being executed (process_template.php):

<?php
// some PHP script (containing NO HTML tags), which is loading and processing template files, according to arguments supplied
...
?>

Do anybody know PHPSavant and Smarty better than me (had used them) and can tell me which of these two is capable to meet my needs, please?

yeah ::::
me too have the same problem with smarty.....

http://mannan.zabvision.edu.pk

I know this thread is very old but for everyone who asks about using smarty or phpsavant:
I can recommend everyone to use phpsavant instead of any other template engine.

The most important advantage of PHPsavant is the speed of executing the scripts. In contrast to a template engine e.g. smarty PHPsavant doesnt need to compile the code because it is already php code. Therefore no template engine can be faster than PHPsavant.

The next advantage of Savant is that you dont need to learn a new language. If you are familiar with PHP you can use PHPsavant without any problems.

Another advantage of PHPsavant is that you can do anything you want because you are writing PHP code. Using smarty you are restricted to the functions and plugins which already exist. Of course you can write a new plugin on your own but then you have to know how to do this.

At last one little disadvantage of PHPsavant: the templaltes are not as clean as they will be if you are using Smarty. One example:

Sample template using smarty:

<body>
 <div>{$variable}</div>
</body>

Sample template using PHPsavant:

<body>
 <div><?php echo $this->variable ?></div>
</body>

This is a link to a discussion about smarty and PHPsavant.

And if you dont see the wood for the treest: PHP is already a template engine!

With short_open_tag=On in the ini file, you could write it like this:

<body>
 <div><?= $this->variable ?></div>
</body>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.