/** * Get the laravel view factory. * * @return Factory */ protected function getViewFactory() { if ($this->factory) { return $this->factory; } $resolver = new EngineResolver(); $resolver->register("blade", function () { if (!is_dir($this->cache)) { mkdir($this->cache, 0777, true); } $blade = new BladeCompiler(new Filesystem(), $this->cache); Blade::registerDirectives($blade); return new CompilerEngine($blade); }); $this->factory = new Factory($resolver, $this->getViewFinder(), new Dispatcher()); return $this->factory; }
public function testCustomCompiler() { Blade::extend(function ($value) { return str_replace("Original", "New", $value); }); $result = Blade::render("view12"); $this->assertSame(file_get_contents(__DIR__ . "/views/view12.html"), $result); }
/** * Add content to the body of the message. * * @param string $view The name of the view to use * @param array $params Parameters to pass to the view * * @return static */ public function addView($view, array $params = null) { if (!is_array($params)) { $params = []; } $content = Blade::make($view, $params); return $this->addContent($content); }
public function setUp() { $this->blade = new BladeCompiler(new Filesystem(), "/tmp/phpunit/cache/views"); Blade::registerDirectives($this->blade); }