Welcome Guest, Not a member yet? Register   Sign In
Which template system should I use ?
#2

[eluser]Rick Jolly[/eluser]
Good template engines will "compile" the template into php, so there isn't much of a performance hit. I've used Html_Template_Flexy and phptal with CI. Many others use Smarty.

Html_Template_Flexy is nice because it treats form fields as serializable objects - like asp.net form controls. It will save the form field state automatically, so there is no need to populate/repopulate form data in your views. It also allows you to set form field attributes in the controller in an object oriented way - again, just like asp.net.

Phptal is nice because it is a template attribute language. You'd need to read the documentation to appreciate that, but it allows you to create templates often without the {} syntax - the variables/conditionals/loops can all be defined within html tags. Here is the example from the phptal docs:
Code:
<?xml version="1.0"?>
<html>
  <head>
    <title tal:content="title">
      this will be replaced with a dynamic page title
    </title>
  </head>
  <body>
    <h1 tal:content="title">this will be replaced with a dynamic page title</h1>
    <table>
      <thead>
        <tr>
          <th>name</th>
          <th>phone</th>
        </tr>
      </thead>
      <tbody>
        <tr tal:repeat="item result">
          <td tal:content="item/name">item name</td>
          <td tal:content="item/phone">item phone</td>
        </tr>
        <tr tal:replace="">
          <td>sample name - this row will not be visible when running on the server</td>
          <td>sample phone - this row will not be visible when running on the server</td>
        </tr>
      </tbody>
    </table>
  &lt;/body&gt;
&lt;/html&gt;


Messages In This Thread
Which template system should I use ? - by El Forum - 10-09-2007, 03:52 PM
Which template system should I use ? - by El Forum - 10-09-2007, 06:02 PM
Which template system should I use ? - by El Forum - 10-09-2007, 07:51 PM
Which template system should I use ? - by El Forum - 10-09-2007, 08:07 PM
Which template system should I use ? - by El Forum - 10-09-2007, 08:14 PM
Which template system should I use ? - by El Forum - 10-09-2007, 09:44 PM
Which template system should I use ? - by El Forum - 10-10-2007, 01:21 AM
Which template system should I use ? - by El Forum - 10-10-2007, 05:11 AM
Which template system should I use ? - by El Forum - 10-10-2007, 07:46 AM
Which template system should I use ? - by El Forum - 10-10-2007, 09:22 AM
Which template system should I use ? - by El Forum - 10-10-2007, 09:47 AM
Which template system should I use ? - by El Forum - 10-10-2007, 09:51 AM
Which template system should I use ? - by El Forum - 10-10-2007, 10:53 AM
Which template system should I use ? - by El Forum - 10-10-2007, 11:56 AM
Which template system should I use ? - by El Forum - 10-10-2007, 12:03 PM
Which template system should I use ? - by El Forum - 10-10-2007, 12:23 PM
Which template system should I use ? - by El Forum - 10-10-2007, 12:28 PM
Which template system should I use ? - by El Forum - 10-10-2007, 12:36 PM
Which template system should I use ? - by El Forum - 10-10-2007, 01:40 PM
Which template system should I use ? - by El Forum - 10-10-2007, 01:57 PM
Which template system should I use ? - by El Forum - 10-12-2007, 09:30 AM
Which template system should I use ? - by El Forum - 10-12-2007, 01:53 PM
Which template system should I use ? - by El Forum - 10-20-2007, 03:43 AM
Which template system should I use ? - by El Forum - 10-20-2007, 11:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB