Skip to content

写的挺好的。 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
shalao opened this issue Mar 16, 2019 · 1 comment
Open

写的挺好的。 #10

shalao opened this issue Mar 16, 2019 · 1 comment

Comments

@shalao
Copy link

shalao commented Mar 16, 2019

十二章,Compiler类中

public function compile($file = null, $params = [])
{
$path = '../views/'.$file.'.sf';
extract($params);
if (!$this->isExpired($path)) {
$compiled = $this->getCompiledPath($path);
require_once $compiled;

          return;
      }   
      $fileContent = file_get_contents($path);
      $result = ''; 
      foreach (token_get_all($fileContent) as $token) {
          if (is_array($token)) {
              list($id, $content) = $token;
              if ($id == T_INLINE_HTML) {
                  foreach ($this->compilers as $type) {
                      $content = $this->{"compile{$type}"}($content); //这个是不是改成拼接呢 $content .= $this->{"compile{$type}"}($content); 
                  }   
              }   
              $result .= $content;
          } else {
              $result .= $token;
          }   
      }   
      $compiled = $this->getCompiledPath($path);
      file_put_contents($compiled, $result);
      require_once $compiled;
  }   
@Pnmrayong
Copy link

Pnmrayong commented Nov 22, 2024

十二章,Compiler类中

public function compile($file = null, $params = [])
{
$path = '../views/'.$file.'.sf';
extract($params);
if (!$this->isExpired($path)) {
$compiled = $this->getCompiledPath($path);
require_once $compiled;

          return;
      }   
      $fileContent = file_get_contents($path);
      $result = ''; 
      foreach (token_get_all($fileContent) as $token) {
          if (is_array($token)) {
              list($id, $content) = $token;
              if ($id == T_INLINE_HTML) {
                  foreach ($this->compilers as $type) {
                      $content = $this->{"compile{$type}"}($content); //这个是不是改成拼接呢 $content .= $this->{"compile{$type}"}($content); 
                  }   
              }   
              $result .= $content;
          } else {
              $result .= $token;
          }   
      }   
      $compiled = $this->getCompiledPath($path);
      file_put_contents($compiled, $result);
      require_once $compiled;
  }   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants