浏览代码

View\Compiler: Edit regular expressions

Visman 1 年之前
父节点
当前提交
e42fc8d9f0
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      app/Core/View/Compiler.php

+ 4 - 4
app/Core/View/Compiler.php

@@ -65,7 +65,7 @@ class Compiler
         $pre = $this->preArray[$this->tplName] ?? null;
         $pre = $this->preArray[$this->tplName] ?? null;
 
 
         return \preg_replace_callback(
         return \preg_replace_callback(
-            '%[ \t]*+<!-- PRE (\w+) -->[ \t]*\r?\n?%',
+            '%^[ \t]*+<!-- PRE (\w+) -->[ \t]*(?:\r?\n)?%m',
             function($match) use ($pre) {
             function($match) use ($pre) {
                 if (isset($pre[$match[1]])) {
                 if (isset($pre[$match[1]])) {
                     return \rtrim($pre[$match[1]]) . "\n";
                     return \rtrim($pre[$match[1]]) . "\n";
@@ -110,7 +110,7 @@ class Compiler
     {
     {
         // {{! !}}
         // {{! !}}
         $value = \preg_replace_callback(
         $value = \preg_replace_callback(
-            '%(@)?\{\{!\s*(.+?)\s*!\}\}(\r?\n)?%s',
+            '%(@)?\{\{![ \t]*+(.+?)[ \t]*!\}\}(\r?\n)?%',
             function($matches) {
             function($matches) {
                 $whitespace = empty($matches[3]) ? '' : $matches[3] . $matches[3];
                 $whitespace = empty($matches[3]) ? '' : $matches[3] . $matches[3];
 
 
@@ -126,7 +126,7 @@ class Compiler
 
 
         // {!! !!}
         // {!! !!}
         $value = \preg_replace_callback(
         $value = \preg_replace_callback(
-            '%\{\!!\s*(.+?)\s*!!\}(\r?\n)?%s',
+            '%\{\!![ \t]*+(.+?)[ \t]*!!\}(\r?\n)?%',
             function($matches) {
             function($matches) {
                 $whitespace = empty($matches[2]) ? '' : $matches[2] . $matches[2];
                 $whitespace = empty($matches[2]) ? '' : $matches[2] . $matches[2];
 
 
@@ -140,7 +140,7 @@ class Compiler
 
 
         // {{ }}
         // {{ }}
         $value = \preg_replace_callback(
         $value = \preg_replace_callback(
-            '%(@)?\{\{\s*(.+?)\s*\}\}(\r?\n)?%s',
+            '%(@)?\{\{(?!!)[ \t]*+(.+?)[ \t]*\}\}(\r?\n)?%',
             function($matches) {
             function($matches) {
                 $whitespace = empty($matches[3]) ? '' : $matches[3] . $matches[3];
                 $whitespace = empty($matches[3]) ? '' : $matches[3] . $matches[3];