From 602f9a0f44d9101c0fce12a2694d75a2e1f51136 Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 20 Dec 2000 15:36:13 +0000 Subject: [PATCH] Added support for inserting results of function processing a template. --- Smarty.class.php | 23 +++++++++++++++++++++++ libs/Smarty.class.php | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/Smarty.class.php b/Smarty.class.php index 201b6a26..a71e06e2 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -450,6 +450,9 @@ class Smarty list (,$literal_block) = each($this->_literal_blocks); return $literal_block; + case 'insert': + return $this->_compile_insert_tag($tag_args); + default: if (isset($this->custom_tags[$tag_command])) { return $this->_compile_custom_tag($tag_command, $tag_args); @@ -474,6 +477,26 @@ class Smarty } + function _compile_insert_tag($tag_args) + { + $attrs = $this->_parse_attrs($tag_args); + $name = substr($attrs['name'], 1, -1); + + if (empty($name)) { + /* TODO syntax error: missing insert name */ + } + + foreach ($attrs as $arg_name => $arg_value) { + if ($arg_name == 'name') continue; + if (is_bool($arg_value)) + $arg_value = $arg_value ? 'true' : 'false'; + $arg_list[] = "'$arg_name' => $arg_value"; + } + + return ""; + } + + function _compile_config_load_tag($tag_args) { $attrs = $this->_parse_attrs($tag_args); diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 201b6a26..a71e06e2 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -450,6 +450,9 @@ class Smarty list (,$literal_block) = each($this->_literal_blocks); return $literal_block; + case 'insert': + return $this->_compile_insert_tag($tag_args); + default: if (isset($this->custom_tags[$tag_command])) { return $this->_compile_custom_tag($tag_command, $tag_args); @@ -474,6 +477,26 @@ class Smarty } + function _compile_insert_tag($tag_args) + { + $attrs = $this->_parse_attrs($tag_args); + $name = substr($attrs['name'], 1, -1); + + if (empty($name)) { + /* TODO syntax error: missing insert name */ + } + + foreach ($attrs as $arg_name => $arg_value) { + if ($arg_name == 'name') continue; + if (is_bool($arg_value)) + $arg_value = $arg_value ? 'true' : 'false'; + $arg_list[] = "'$arg_name' => $arg_value"; + } + + return ""; + } + + function _compile_config_load_tag($tag_args) { $attrs = $this->_parse_attrs($tag_args);