forked from jbboehr/php-mustache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mustache.php
264 lines (231 loc) · 5.64 KB
/
mustache.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php
class Mustache
{
/**
* Constructor
*/
public function __construct() {}
/**
* Gets whether to escape HTML by default. Defaults to true
*
* @return boolean Whether to escapt HTML by default
*/
public function getEscapeByDefault() {}
/**
* Gets the start delimiter. Defaults to "{{"
*
* @return string The start delimiter
*/
public function getStartSequence() {}
/**
* Gets the stop delimiter. Defaults to "}}"
*
* @return string The stop delimiter
*/
public function getStopSequence() {}
/**
* Sets whether to escape HTML by default
*
* @param boolean $flag
* @return boolean true on success, false on failure
*/
public function setEscapeByDefault($flag) {}
/**
* Sets the start delimiter.
*
* @param type $start
* @return boolean true on success, false on failure
*/
public function setStartSequence($start) {}
/**
* Sets the stop delimiter.
*
* @param string $stop
* @return boolean true on success, false on failure
*/
public function setStopSequence($stop) {}
/**
* Tokenizes and parses a template and returns a class representing it.
*
* @param mixed $tmpl The input template. May be a string or an instance
* of MustacheTemplate
* @return MustacheAST The compiled template
*/
public function parse($tmpl) {}
/**
* Renders a template
*
* @param mixed $tmpl The input template. May be a string, or an instance of
* MustacheTemplate or MustacheAST
* @param mixed $data The input data. May be any array, scalar, or object,
* or an instance of MustacheData
* @param mixed $partials (Optional) The template partials. Must be an array
* with each value either a string, or an instance of
* MustacheTemplate or MustacheAST
* @return false|string The string output, or false on failure
*/
public function render($tmpl, $data, $partials = null) {}
/**
* Compiles a template and returns an array representing the internal
* structure.
*
* @param string $tmpl The input template
* @return array The compiled template structure
*/
public function tokenize($tmpl) {}
/**
* Converts an array into the internal data structure and back. Used for
* debugging.
*
* @param array $data The input data
* @return array The converted data structure
*/
public function debugDataStructure(array $data) {}
}
/**
* Represents the parsed AST
*/
class MustacheAST
{
/**
* Constructor.
*
* @param string $binaryString The serialized AST string
*/
public function __construct($binaryString = null) {}
/**
* Stores the AST in a string property
*
* @return array
*/
public function __sleep() {}
/**
* Compiles a template and returns an array representing the internal
* structure. Alias of Mustache::tokenize()
*
* @return array The compiled template structure
*/
public function toArray() {}
/**
* Gets the serialized binary AST
*
* @return string The template string
*/
public function __toString() {}
/**
* Restores the string properies to the internal C structure
*
* @return void
*/
public function __wakeup() {}
}
class MustacheCode
{
/**
* Constructor
*
* @param string $codeString
*/
public function __construct($codeString) {}
/**
* Returns a readable version of the bytecode
*
* @return string
*/
public function toReadableString() {}
/**
* Stores the bytecode in a string property for serialization
*
* @return array
*/
public function __sleep() {}
/**
* Converts the bytecode to a string
*/
public function __toString() {}
/**
* Restores the string properies to the internal C structure
*
* @return void
*/
public function __wakeup() {}
}
class MustacheTemplate
{
/**
* Constructor.
*
* @param string $tmpl The input template
*/
public function __construct($tmpl = null) {}
/**
* Stores the C uncompiled and compiled templates in string properties
*
* @return array
*/
public function __sleep() {}
/**
* Sets the internal compiled template to a binary string representing the
* internal structure.
*
* @return void
*/
public function setFromBinary($binaryString) {}
/**
* Compiles a template and returns an array representing the internal
* structure. Alias of Mustache::tokenize()
*
* @return array The compiled template structure
*/
public function toArray() {}
/**
* Compiles a template and returns a binary string representing the internal
* structure.
*
* @return string The serialized compiled template structure
*/
public function toBinary() {}
/**
* Gets the string version of the template
*
* @return string The template string
*/
public function __toString() {}
/**
* Restores the string properies to the internal C structure
*
* @return void
*/
public function __wakeup() {}
}
class MustacheData
{
/**
* Constructor
*
* @param mixed $data The input data
*/
public function __construct($data) {}
/**
* Gets the internal data
*
* @return mixed The internal data
*/
public function toValue() {}
}
class MustacheException extends Exception {}
class MustacheParserException extends MustacheParserException
{
/**
* The line number of the parse error
*
* @var integer
*/
public $templateLineNo;
/**
* The character number of the parse error
*
* @var integer
*/
public $templateCharNo;
}