forked from gabordemooij/stamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.php
96 lines (77 loc) · 1.89 KB
/
examples.php
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
<?php
require('StampTE.php');
$template = '
<div>
<!-- cut:diamond -->
<img src="diamond.gif" />
<!-- /cut:diamond -->
</div>
<div id="box">
<!-- paste:jewellery -->
</div>
';
$se = new StampTE($template);
$diamond = $se->get('diamond');
echo $diamond;
$diamond = $se->get('diamond');
$se->glue('jewellery',$diamond);
echo $se;
$template = '
<!-- cut:form -->
<form action="#action#" method="#method#">
<!-- paste:formElements -->
<!-- cut:textfield -->
<label>#label#</label>
<input type="text" name="#name#" value="#value#" />
<!-- /cut:textfield -->
<input type="submit" name="#send#" />
</form>
<!-- /cut:form -->
';
$se = new StampTE($template);
list($form,$textfield) = $se->collect('form|form.textfield');
$form->glue('formElements',
$textfield->copy()->injectAll(array(
'label'=>'Your name',
'name'=>'username',
'value'=>'...your name please...'))
)->inject('send','Update your Profile');
echo $form;
$template = "
<!-- cut:table -->
<table>
<thead>
<tr>
<!-- paste:columns(column,data) -->
<!-- cut:column -->
<th>#column#</th>
<!-- /cut:column -->
</tr>
</thead>
<tbody>
<!-- paste:rows -->
<!-- cut:row -->
<tr>
<!-- paste:cells -->
<!-- cut:cell -->
<td>#cell#</td>
<!-- /cut:cell -->
</tr>
<!-- /cut:row -->
</tbody>
</table>
<!-- /cut:table -->
";
$columns = array('Pizza','Price');
$data = array(array('Pepperoni','7.99'),array('Veggie','6.99'));
$se = new StampTE($template);
list($table,$columnHead,$row,$cell) = $se->collect('table|table.column|table.row|table.row.cell');
foreach($columns as $column) $table->glue('columns',$columnHead->copy()->inject('column',$column));
foreach($data as $pizzaInfoLine) {
$pizzaRow = $row->copy();
foreach($pizzaInfoLine as $pizzaInfo) {
$pizzaRow->glue('cells',$cell->copy()->inject('cell',$pizzaInfo));
}
$table->glue('rows',$pizzaRow);
}
echo $table;