|
Smarty is a library that allows the creation of HTML templates that
are imported and used in PHPRunner scripts to ease the process of web
page design. Smarty cleanly separates your presentation elements
(HTML, CSS, etc.) from your application code.
Template files (*.htm) can be found in template
directory inside output directory.
Here is the basic example of how Smarty works:
list.php |
include('Smarty.class.php');
// create object $smarty = new Smarty;
// assign some content. This would typically come from // a database or other source, but we'll use static // values for the purpose of this example. $smarty->assign('name', 'george smith'); $smarty->assign('address', '45th & Harris');
// display it $smarty->display('list.htm');
|
The template file then contains the output interspersed with tags
that Smarty replaces with assigned content.
list.htm |
|
output |
<html> <head> <title>User Info</title> </head> <body>
User Information:<p>
Name: {$name}<br> Address: {$address}<br>
</body> </html>
|
|
<html> <head> <title>User Info</title> </head> <body>
User Information:<p>
Name: george smith<br> Address: 45th & Harris<br>
</body> </html>
|
More info:
Official Smarty web site
(documentation, examples, FAQ, wiki etc) |