/** * render * * @param $string * @param array $vars * @return string */ public function render($string, array $vars = array()) { $this->files->put($this->tmpFilePath, $this->compiler->compileString($string)); if (is_array($vars) && !empty($vars)) { extract($vars); } ob_start(); include $this->tmpFilePath; $var = ob_get_contents(); ob_end_clean(); $this->files->delete($this->tmpFilePath); return $var; }
public function render($str, array $vars = []) { $__tmp_stub_file = Str::random() . uniqid(time(), false); !$this->fs->exists($this->cachePath) && $this->fs->makeDirectory($this->cachePath, 0755, true); $__tmp_stub_path = Path::join($this->cachePath, $__tmp_stub_file); $this->fs->put($__tmp_stub_path, $this->compiler->compileString($str)); $__env = $this->getViewFactory(); if (is_array($vars) && 0 !== count($vars)) { extract($vars); } ob_start(); include $__tmp_stub_path; $var = ob_get_contents(); ob_end_clean(); $this->fs->delete($__tmp_stub_path); return $var; }