mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Preserve line numbers when compiling templates
This commit is contained in:
parent
770cde8b8a
commit
cd8e6371c6
2 changed files with 51 additions and 35 deletions
|
|
@ -266,6 +266,11 @@ class TemplateHandler
|
|||
{
|
||||
return;
|
||||
}
|
||||
$buff_type = 'file';
|
||||
}
|
||||
else
|
||||
{
|
||||
$buff_type = 'string';
|
||||
}
|
||||
|
||||
// HTML tags to skip
|
||||
|
|
@ -313,7 +318,17 @@ class TemplateHandler
|
|||
$buff = self::_replaceTempEntities($buff);
|
||||
|
||||
// remove php script reopening
|
||||
$buff = preg_replace(array('/(\n|\r\n)+/', '/(;)?( )*\?\>\<\?php([\n\t ]+)?/'), array("\n", ";\n"), $buff);
|
||||
$buff = preg_replace_callback('/([;{])?( )*\?\>\<\?php\s/', function($match) {
|
||||
return $match[1] === '{' ? '{ ' : '; ';
|
||||
}, $buff);
|
||||
|
||||
// remove empty lines
|
||||
if ($buff_type === 'file')
|
||||
{
|
||||
$buff = rtrim($buff) . PHP_EOL;
|
||||
}
|
||||
$buff = preg_replace('/\n[\t\x20]*?(?=\n)/', "\n<?php ?>", $buff);
|
||||
$buff = preg_replace('/\n[\t\x20]+?\<\?php/', "\n<?php", $buff);
|
||||
|
||||
// restore config to previous value
|
||||
$this->config = $previous_config;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue