Esempio n. 1
0
 protected function compile()
 {
     $contents = $this->content ?: $this->file->read();
     $contents = str_replace(array_keys($this->phpTags), array_values($this->phpTags), $contents);
     // Escape php tags
     $contents = '<?php set_error_handler($_errorHandler);unset($_errorHandler); ?>' . $contents . '<?php restore_error_handler(); ?>';
     $replace = [];
     preg_match_all('#\\{(!?\\$[\\w]+)\\}#', $contents, $matches);
     // {[!]$var}
     foreach ($matches[1] as $match) {
         $full = '{' . $match . '}';
         $var = str_replace(['!'], '', $match);
         if (!in_array($var, $this->forbidden)) {
             $replace[$full] = $this->echoVar($var, !$this->autoEscape ? FALSE : !Strings::startsWith($match, '!'));
         }
     }
     $contents = str_replace(array_keys($replace), array_values($replace), $contents);
     $this->createCache($contents);
 }