mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
Prepend code in postprocessing, not preprocessing
This commit is contained in:
parent
1067588754
commit
6893e08553
1 changed files with 9 additions and 9 deletions
|
|
@ -120,15 +120,6 @@ class TemplateParser_v2
|
|||
*/
|
||||
protected function _preprocess(string $content): string
|
||||
{
|
||||
// Force the version number.
|
||||
if (!str_contains($content, '$this->config->version'))
|
||||
{
|
||||
$content = '<?php $this->config->version = 2; ?>' . $content;
|
||||
}
|
||||
|
||||
// Prevent direct invocation.
|
||||
$content = '<?php if (!defined("RX_VERSION")) exit(); ?>' . $content;
|
||||
|
||||
// Remove trailing whitespace.
|
||||
$content = preg_replace('#[\x20\x09]+$#m', '', $content);
|
||||
|
||||
|
|
@ -951,6 +942,15 @@ class TemplateParser_v2
|
|||
'#@(\{\{)#',
|
||||
], '$1', $content);
|
||||
|
||||
// Prepend the version number.
|
||||
if (!str_contains($content, '$this->config->version'))
|
||||
{
|
||||
$content = '<?php $this->config->version = 2; ?>' . $content;
|
||||
}
|
||||
|
||||
// Prepend constant check to block direct invocation of the cache file.
|
||||
$content = '<?php if (!defined("RX_VERSION")) exit(); ?>' . $content;
|
||||
|
||||
// Remove unnecessary spaces before and after PHP tags.
|
||||
$content = preg_replace([
|
||||
'#^[\x20\x09]+(<\?(?:php\b|=))#m',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue