| 1 |
dc33f417
|
Seldaek |
----------------------------------------------------------------------------- |
|
| 2 |
27642e40
|
seldaek |
-- WHAT IS DWOO? readme - version 1.1.0 |
|
| 3 |
dc33f417
|
Seldaek |
----------------------------------------------------------------------------- |
|
| 4 |
eec2dabe
|
Seldaek |
Dwoo is a PHP5 Template Engine that was started in early 2008. The idea came |
|
| 5 |
dc33f417
|
Seldaek |
from the fact that Smarty, a well known template engine, is getting older and |
|
| 6 |
eec2dabe
|
Seldaek |
older. It carries the weight of it's age, having old features that are |
|
| 7 |
↓
|
Seldaek |
inconsistent compared to newer ones, being written for PHP4 its Object |
|
| 8 |
↓
|
Seldaek |
Oriented aspect doesn't take advantage of PHP5's more advanced features in |
|
| 9 |
↓
|
Seldaek |
the area, etc. Hence Dwoo was born, hoping to provide a more up to date and |
|
| 10 |
↓
|
Seldaek |
stronger engine. |
|
| 11 |
↓
|
Seldaek |
|
|
| 12 |
↓
|
Seldaek |
So far it has proven to be faster than Smarty in many areas, and it provides |
|
| 13 |
↓
|
Seldaek |
a compatibility layer to allow developers that have been using Smarty for |
|
| 14 |
dc33f417
|
Seldaek |
years to switch their application over to Dwoo progressively. |
|
| 15 |
↓
|
Seldaek |
|
|
| 16 |
↓
|
Seldaek |
----------------------------------------------------------------------------- |
|
| 17 |
↓
|
Seldaek |
-- DOCUMENTATION |
|
| 18 |
↓
|
Seldaek |
----------------------------------------------------------------------------- |
|
| 19 |
↓
|
Seldaek |
Dwoo's website to get the latest version is at http://dwoo.org/ |
|
| 20 |
↓
|
Seldaek |
|
|
| 21 |
↓
|
Seldaek |
The wiki/documentation pages are available at http://wiki.dwoo.org/ |
|
| 22 |
↓
|
Seldaek |
|
|
| 23 |
↓
|
Seldaek |
----------------------------------------------------------------------------- |
|
| 24 |
↓
|
Seldaek |
-- LICENSE |
|
| 25 |
↓
|
Seldaek |
----------------------------------------------------------------------------- |
|
| 26 |
2fd2c90f
|
seldaek |
Dwoo is released under the Modified BSD license. |
|
| 27 |
dc33f417
|
Seldaek |
See the LICENSE file included in the archive or go to the URL below to obtain |
|
| 28 |
↓
|
Seldaek |
a copy. |
|
| 29 |
↓
|
Seldaek |
|
|
| 30 |
2fd2c90f
|
seldaek |
http://dwoo.org/LICENSE |
|
| 31 |
dc33f417
|
Seldaek |
|
|
| 32 |
↓
|
Seldaek |
----------------------------------------------------------------------------- |
|
| 33 |
↓
|
Seldaek |
-- QUICK START - RUNNING DWOO |
|
| 34 |
↓
|
Seldaek |
----------------------------------------------------------------------------- |
|
| 35 |
↓
|
Seldaek |
/***************************** Basic Example *******************************/ |
|
| 36 |
↓
|
Seldaek |
// Include the main class (it should handle the rest on its own) |
|
| 37 |
478bf677
|
Seldaek |
include 'path/to/dwooAutoload.php'; |
|
| 38 |
dc33f417
|
Seldaek |
|
|
| 39 |
↓
|
Seldaek |
// Create the controller, this is reusable |
|
| 40 |
↓
|
Seldaek |
$dwoo = new Dwoo(); |
|
| 41 |
↓
|
Seldaek |
|
|
| 42 |
↓
|
Seldaek |
// Load a template file (name it as you please), this is reusable |
|
| 43 |
↓
|
Seldaek |
// if you want to render multiple times the same template with different data |
|
| 44 |
eec2dabe
|
Seldaek |
$tpl = new Dwoo_Template_File('path/to/index.tpl'); |
|
| 45 |
dc33f417
|
Seldaek |
|
|
| 46 |
↓
|
Seldaek |
// Create a data set, if you don't like this you can directly input an |
|
| 47 |
↓
|
Seldaek |
// associative array in $dwoo->output() |
|
| 48 |
eec2dabe
|
Seldaek |
$data = new Dwoo_Data(); |
|
| 49 |
dc33f417
|
Seldaek |
// Fill it with some data |
|
| 50 |
↓
|
Seldaek |
$data->assign('foo', 'BAR'); |
|
| 51 |
↓
|
Seldaek |
$data->assign('bar', 'BAZ'); |
|
| 52 |
↓
|
Seldaek |
|
|
| 53 |
↓
|
Seldaek |
// Outputs the result ... |
|
| 54 |
↓
|
Seldaek |
$dwoo->output($tpl, $data); |
|
| 55 |
↓
|
Seldaek |
// ... or get it to use it somewhere else |
|
| 56 |
↓
|
Seldaek |
$dwoo->get($tpl, $data); |
|
| 57 |
↓
|
Seldaek |
|
|
| 58 |
↓
|
Seldaek |
/***************************** Loop Example *******************************/ |
|
| 59 |
↓
|
Seldaek |
// To loop over multiple articles of a blog for instance, if you have a |
|
| 60 |
↓
|
Seldaek |
// template file representing an article, you could do the following : |
|
| 61 |
↓
|
Seldaek |
|
|
| 62 |
478bf677
|
Seldaek |
include 'path/to/dwooAutoload.php'; |
|
| 63 |
dc33f417
|
Seldaek |
|
|
| 64 |
↓
|
Seldaek |
$dwoo = new Dwoo(); |
|
| 65 |
eec2dabe
|
Seldaek |
$tpl = new Dwoo_Template_File('path/to/article.tpl'); |
|
| 66 |
dc33f417
|
Seldaek |
|
|
| 67 |
↓
|
Seldaek |
$pageContent = ''; |
|
| 68 |
↓
|
Seldaek |
|
|
| 69 |
↓
|
Seldaek |
// Loop over articles that have been retrieved from the DB |
|
| 70 |
↓
|
Seldaek |
foreach($articles as $article) { |
|
| 71 |
↓
|
Seldaek |
// Either associate variables one by one |
|
| 72 |
eec2dabe
|
Seldaek |
$data = new Dwoo_Data(); |
|
| 73 |
dc33f417
|
Seldaek |
$data->assign('title', $article['title']; |
|
| 74 |
↓
|
Seldaek |
$data->assign('content', $article['content']); |
|
| 75 |
↓
|
Seldaek |
$pageContent .= $dwoo->get($tpl, $data); |
|
| 76 |
↓
|
Seldaek |
|
|
| 77 |
↓
|
Seldaek |
// Or use the article directly (which is a lot easier in this case) |
|
| 78 |
↓
|
Seldaek |
$pageContent .= $dwoo->get($tpl, $article); |
|
| 79 |
e31da1c6
|
Seldaek |
} |
|