diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..c4da3f9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Talesoft GbR + +Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce3f7f2 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Tale Jade for Laravel + +--- + +This library provides the ability to use [Jade](http://github.com/Talesoft/tale-jade)-templates with the Laravel Framework + +--- + +## Usage + +Download and install via composer + +```bash +$ composer require "talesoft/tale-jade-laravel:*" +$ composer install +``` + + +Add the service provider to your `config/app.php`-file (Right below the other ones) + +```php + /* + * Application Service Providers... + */ + App\Providers\AppServiceProvider::class, + App\Providers\AuthServiceProvider::class, + App\Providers\EventServiceProvider::class, + App\Providers\RouteServiceProvider::class, + [...] + + + Tale\Jade\Bridge\Laravel\ServiceProvider::class, + +``` + + +You can now create `.jade`-files inside your `resources/views` directory and use them directly. +All features work correctly. + diff --git a/src/Engine.php b/src/Engine.php index 0f528b3..e654b7d 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -5,7 +5,9 @@ use Tale\Jade\Renderer; /** - * Laravel view engine for Jade. + * A View Engine Wrapper for Jade in Laravel. + * + * {@inheritDoc} */ class Engine implements EngineInterface { @@ -19,12 +21,21 @@ public function __construct(Renderer $renderer) } /** - * {@inheritdoc} - * + * {@inheritDoc} */ public function get($path, array $data = array()) { + $rendererOptions = $this->_renderer->getOptions(); + + //Strip the include paths + foreach ($rendererOptions['compilerOptions']['paths'] as $includePath) { + + $len = strlen($includePath); + if (strncmp($includePath, $path, $len) === 0) + $path = substr($path, $len); + } + return $this->_renderer->render($path, $data); } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 7206f67..af3e019 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -5,9 +5,17 @@ use Illuminate\Support\ServiceProvider as LaravelServiceProvider; use Tale\Jade\Renderer; +/** + * Provides the ability to use Jade templates in Laravel. + * + * {@inheritDoc} + */ class ServiceProvider extends LaravelServiceProvider { + /** + * {@inheritDoc} + */ public function register() { @@ -17,6 +25,7 @@ public function register() $app['jade'] = $app->share(function($app) { $app['jade.options'] = array_replace([ + 'paths' => $app['config']['view.paths'], 'adapter' => 'file', 'adapterOptions' => [ 'path' => $app['path.storage'].'/jade' @@ -28,12 +37,18 @@ public function register() }); } + /** + * {@inheritDoc} + */ public function provides() { return ['jade', 'jade.options']; } + /** + * {@inheritDoc} + */ public function boot() {