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?

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>
This article has been dead for over six months. Start a new discussion instead.