]> git.mxchange.org Git - friendica.git/blob - vendor/smarty/smarty/libs/sysplugins/smarty_internal_parsetree_tag.php
Add Smarty to Composer
[friendica.git] / vendor / smarty / smarty / libs / sysplugins / smarty_internal_parsetree_tag.php
1 <?php
2 /**
3  * Smarty Internal Plugin Templateparser Parse Tree
4  * These are classes to build parse tree in the template parser
5  *
6  * @package    Smarty
7  * @subpackage Compiler
8  * @author     Thue Kristensen
9  * @author     Uwe Tews
10  */
11
12 /**
13  * A complete smarty tag.
14  *
15  * @package    Smarty
16  * @subpackage Compiler
17  * @ignore
18  */
19 class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
20 {
21
22     /**
23      * Saved block nesting level
24      *
25      * @var int
26      */
27     public $saved_block_nesting;
28
29     /**
30      * Create parse tree buffer for Smarty tag
31      *
32      * @param \Smarty_Internal_Templateparser $parser parser object
33      * @param string                          $data   content
34      */
35     public function __construct(Smarty_Internal_Templateparser $parser, $data)
36     {
37         $this->data = $data;
38         $this->saved_block_nesting = $parser->block_nesting_level;
39     }
40
41     /**
42      * Return buffer content
43      *
44      * @param \Smarty_Internal_Templateparser $parser
45      *
46      * @return string content
47      */
48     public function to_smarty_php(Smarty_Internal_Templateparser $parser)
49     {
50         return $this->data;
51     }
52
53     /**
54      * Return complied code that loads the evaluated output of buffer content into a temporary variable
55      *
56      * @param \Smarty_Internal_Templateparser $parser
57      *
58      * @return string template code
59      */
60     public function assign_to_var(Smarty_Internal_Templateparser $parser)
61     {
62         $var = $parser->compiler->getNewPrefixVariable();
63         $tmp = $parser->compiler->appendCode('<?php ob_start();?>', $this->data);
64         $tmp = $parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
65         $parser->compiler->prefix_code[] = sprintf("%s", $tmp);
66
67         return $var;
68     }
69 }