init
[garradin.git] / include / libs / template_lite / internal / compile.include.php
1 <?php
2 /**
3 * Template Lite
4 *
5 * Type: compile
6 * Name: section_start
7 */
8
9 function compile_include($arguments, &$object)
10 {
11 $_args = $object->_parse_arguments($arguments);
12
13 $arg_list = array();
14 if (empty($_args['file']))
15 {
16 throw new Template_Exception("missing 'file' attribute in include tag", $object);
17 }
18
19 foreach ($_args as $arg_name => $arg_value)
20 {
21 if ($arg_name == 'file')
22 {
23 $include_file = $arg_value;
24 continue;
25 }
26 else if ($arg_name == 'assign')
27 {
28 $assign_var = $arg_value;
29 continue;
30 }
31 if (is_bool($arg_value))
32 {
33 $arg_value = $arg_value ? 'true' : 'false';
34 }
35 $arg_list[] = "'$arg_name' => $arg_value";
36 }
37
38 if (isset($assign_var))
39 {
40 $output = '<?php $_templatelite_tpl_vars = $this->_vars;' .
41 "\n\$this->assign(" . $assign_var . ", \$this->_fetch_compile_include(" . $include_file . ", array(".implode(',', (array)$arg_list).")));\n" .
42 "\$this->_vars = \$_templatelite_tpl_vars;\n" .
43 "unset(\$_templatelite_tpl_vars);\n" .
44 ' ?>';
45 }
46 else
47 {
48 $output = '<?php $_templatelite_tpl_vars = $this->_vars;' .
49 "\necho \$this->_fetch_compile_include(" . $include_file . ", array(".implode(',', (array)$arg_list)."));\n" .
50 "\$this->_vars = \$_templatelite_tpl_vars;\n" .
51 "unset(\$_templatelite_tpl_vars);\n" .
52 ' ?>';
53 }
54 return $output;
55 }
56 ?>