Add template variables for backward compatibility

This commit is contained in:
Kijin Sung 2023-10-27 16:06:48 +09:00
parent dbcbb57413
commit 47db7e6a0b

View file

@ -37,6 +37,12 @@ class Template
public $cache_enabled = true; public $cache_enabled = true;
public $cache_path; public $cache_path;
/**
* Properties for backward compatibility
*/
public $path;
public $web_path;
/** /**
* Properties for state management during compilation/execution * Properties for state management during compilation/execution
*/ */
@ -177,6 +183,8 @@ class Template
$this->config->autoescape = true; $this->config->autoescape = true;
} }
$this->source_type = preg_match('!^((?:m\.)?[a-z]+)/!', $this->relative_dirname, $match) ? $match[1] : null; $this->source_type = preg_match('!^((?:m\.)?[a-z]+)/!', $this->relative_dirname, $match) ? $match[1] : null;
$this->path = $this->absolute_dirname;
$this->web_path = \RX_BASEURL . $this->relative_dirname;
$this->_setCachePath(); $this->_setCachePath();
} }
@ -439,6 +447,7 @@ class Template
{ {
// Import Context and lang as local variables. // Import Context and lang as local variables.
$__Context = $this->vars ?: \Context::getAll(); $__Context = $this->vars ?: \Context::getAll();
$__Context->tpl_path = $this->absolute_dirname;
// Start the output buffer. // Start the output buffer.
$this->_ob_level = ob_get_level(); $this->_ob_level = ob_get_level();