-
Notifications
You must be signed in to change notification settings - Fork 14
/
README
100 lines (73 loc) · 3.86 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
=============================================================================
WARNING - END OF LIFE / UNMAINTAINED CODE
-----------------------------------------------------------------------------
This library is not being maintained anymore for quite a while, so if you are
starting a new project you should probably consider using
[Twig](http://twig.sensiolabs.org) instead.
Another alternative if you have many Dwoo templates is to switch to the
spiritual successor [Dwoo2](https://github.com/emulienfou/dwoo2) library
currently developed by @emulienfou.
=============================================================================
-----------------------------------------------------------------------------
-- WHAT IS DWOO? readme - version 1.1.0
-----------------------------------------------------------------------------
Dwoo is a PHP5 Template Engine that was started in early 2008. The idea came
from the fact that Smarty, a well known template engine, is getting older and
older. It carries the weight of it's age, having old features that are
inconsistent compared to newer ones, being written for PHP4 its Object
Oriented aspect doesn't take advantage of PHP5's more advanced features in
the area, etc. Hence Dwoo was born, hoping to provide a more up to date and
stronger engine.
So far it has proven to be faster than Smarty in many areas, and it provides
a compatibility layer to allow developers that have been using Smarty for
years to switch their application over to Dwoo progressively.
-----------------------------------------------------------------------------
-- DOCUMENTATION
-----------------------------------------------------------------------------
Dwoo's website to get the latest version is at http://dwoo.org/
The wiki/documentation pages are available at http://wiki.dwoo.org/
-----------------------------------------------------------------------------
-- LICENSE
-----------------------------------------------------------------------------
Dwoo is released under the Modified BSD license.
See the LICENSE file included in the archive or go to the URL below to obtain
a copy.
http://dwoo.org/LICENSE
-----------------------------------------------------------------------------
-- QUICK START - RUNNING DWOO
-----------------------------------------------------------------------------
/***************************** Basic Example *******************************/
// Include the main class (it should handle the rest on its own)
include 'path/to/dwooAutoload.php';
// Create the controller, this is reusable
$dwoo = new Dwoo();
// Load a template file (name it as you please), this is reusable
// if you want to render multiple times the same template with different data
$tpl = new Dwoo_Template_File('path/to/index.tpl');
// Create a data set, if you don't like this you can directly input an
// associative array in $dwoo->output()
$data = new Dwoo_Data();
// Fill it with some data
$data->assign('foo', 'BAR');
$data->assign('bar', 'BAZ');
// Outputs the result ...
$dwoo->output($tpl, $data);
// ... or get it to use it somewhere else
$dwoo->get($tpl, $data);
/***************************** Loop Example *******************************/
// To loop over multiple articles of a blog for instance, if you have a
// template file representing an article, you could do the following :
include 'path/to/dwooAutoload.php';
$dwoo = new Dwoo();
$tpl = new Dwoo_Template_File('path/to/article.tpl');
$pageContent = '';
// Loop over articles that have been retrieved from the DB
foreach($articles as $article) {
// Either associate variables one by one
$data = new Dwoo_Data();
$data->assign('title', $article['title'];
$data->assign('content', $article['content']);
$pageContent .= $dwoo->get($tpl, $data);
// Or use the article directly (which is a lot easier in this case)
$pageContent .= $dwoo->get($tpl, $article);
}