Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Evaluates the given string as if it was a template |
---|
5 | * |
---|
6 | * Although this plugin is kind of optimized and will |
---|
7 | * not recompile your string each time, it is still not |
---|
8 | * a good practice to use it. If you want to have templates |
---|
9 | * stored in a database or something you should probably use |
---|
10 | * the Dwoo_Template_String class or make another class that |
---|
11 | * extends it |
---|
12 | * <pre> |
---|
13 | * * var : the string to use as a template |
---|
14 | * * assign : if set, the output of the template will be saved in this variable instead of being output |
---|
15 | * </pre> |
---|
16 | * This software is provided 'as-is', without any express or implied warranty. |
---|
17 | * In no event will the authors be held liable for any damages arising from the use of this software. |
---|
18 | * |
---|
19 | * @author Jordi Boggiano <j.boggiano@seld.be> |
---|
20 | * @copyright Copyright (c) 2008, Jordi Boggiano |
---|
21 | * @license http://dwoo.org/LICENSE Modified BSD License |
---|
22 | * @link http://dwoo.org/ |
---|
23 | * @version 1.0.0 |
---|
24 | * @date 2008-10-23 |
---|
25 | * @package Dwoo |
---|
26 | */ |
---|
27 | function Dwoo_Plugin_eval(Dwoo_Core $dwoo, $var, $assign = null) |
---|
28 | { |
---|
29 | if ($var == '') { |
---|
30 | return; |
---|
31 | } |
---|
32 | |
---|
33 | $tpl = new Dwoo_Template_String($var); |
---|
34 | $clone = clone $dwoo; |
---|
35 | $out = $clone->get($tpl, $dwoo->readVar('_parent')); |
---|
36 | |
---|
37 | if ($assign !== null) { |
---|
38 | $dwoo->assignInScope($out, $assign); |
---|
39 | } else { |
---|
40 | return $out; |
---|
41 | } |
---|
42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.