Latte\Loaders\FileLoader::getContent PHP Method

getContent() public method

Returns template source code.
public getContent ( $file ) : string
return string
    public function getContent($file)
    {
        $file = $this->baseDir . $file;
        if ($this->baseDir && !Latte\Helpers::startsWith($this->normalizePath($file), $this->baseDir)) {
            throw new \RuntimeException("Template '{$file}' is not within the allowed path '{$this->baseDir}'.");
        } elseif (!is_file($file)) {
            throw new \RuntimeException("Missing template file '{$file}'.");
        } elseif ($this->isExpired($file, time())) {
            if (@touch($file) === FALSE) {
                trigger_error("File's modification time is in the future. Cannot update it: " . error_get_last()['message'], E_USER_WARNING);
            }
        }
        return file_get_contents($file);
    }

Usage Example

Example #1
0
 public function getContent($file)
 {
     $content = parent::getContent($file);
     $compiler = new Compiler();
     $compiled = $compiler->compile($content);
     return $compiled;
 }
All Usage Examples Of Latte\Loaders\FileLoader::getContent