From 4c466e33a8b6ebba1783b46c66f287f157582f56 Mon Sep 17 00:00:00 2001 From: Scholer Date: Thu, 6 Jul 2017 23:09:13 +0800 Subject: [PATCH] change readme --- README.md | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 481083d..0b81715 100644 --- a/README.md +++ b/README.md @@ -21,24 +21,39 @@ and then `require` them in your code. ```php directive('datetime', function($timestamp) { return preg_replace('/(\(\d+\))/', '', $timestamp); }); -$engine = new \Xiaoler\Blade\Engines\CompilerEngine($compiler); -$finder = new \Xiaoler\Blade\FileViewFinder($path); - -// if your view file extension is not php or blade.php, use this to add it -$finder->addExtension('tpl'); +$resolver = new EngineResolver; +$resolver->register('blade', function () use ($file, $cachePath) { + return new CompilerEngine(new BladeCompiler($file, $cachePath)); +}); // get an instance of factory -$factory = new \Xiaoler\Blade\Factory($engine, $finder); +$factory = new Factory($resolver, new FileViewFinder($file, $path)); + +// if your view file extension is not php or blade.php, use this to add it +$factory->addExtension('tpl', 'blade'); // render the template file and echo it echo $factory->make('hello', ['a' => 1, 'b' => 2])->render();