- improvement allow fetch() or display() called on a template object to get output from other template

like $template->fetch('foo.tpl') https://github.com/smarty-php/smarty/issues/70
This commit is contained in:
Uwe Tews
2015-07-07 02:01:45 +02:00
parent 5b401789b5
commit bc99747f93
3 changed files with 23 additions and 7 deletions

View File

@@ -1,4 +1,8 @@
 ===== 3.1.28-dev===== (xx.xx.2015)
07.07.2015
- improvement allow fetch() or display() called on a template object to get output from other template
like $template->fetch('foo.tpl') https://github.com/smarty-php/smarty/issues/70
06.07.2015
- optimize {block} compilation
- optimization get rid of __get and __set in source object

View File

@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.28-dev/22';
const SMARTY_VERSION = '3.1.28-dev/24';
/**
* define variable scopes
@@ -791,7 +791,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @throws SmartyException
* @return string rendered template output
*/
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
{
if ($cache_id !== null && is_object($cache_id)) {
$parent = $cache_id;
@@ -816,7 +816,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
*/
public function display($template = null, $cache_id = null, $compile_id = null, $parent = null)
public function display($template, $cache_id = null, $compile_id = null, $parent = null)
{
// display template
$this->fetch($template, $cache_id, $compile_id, $parent, true);

View File

@@ -133,21 +133,33 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
/**
* fetches rendered template
*
* @param string $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
*
* @throws Exception
* @throws SmartyException
* @return string rendered template output
*/
public function fetch()
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null)
{
return $this->render(true, false, false);
return isset($template) ? $this->smarty->fetch($template, $cache_id, $compile_id, $parent) : $this->render(true, false, false);
}
/**
* displays a Smarty template
*
* @param string $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
*
* @return string
*/
public function display()
public function display($template = null, $cache_id = null, $compile_id = null, $parent = null)
{
$this->render(true, false, true);
return isset($template) ? $this->smarty->fetch($template, $cache_id, $compile_id, $parent, true) : $this->render(true, false, true);
}
/**