Skip to content

Commit

Permalink
Tested and it works.
Browse files Browse the repository at this point in the history
  • Loading branch information
Torben Köhn committed Nov 10, 2015
1 parent a0ea594 commit bcb8043
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 3 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 `<template-name>.jade`-files inside your `resources/views` directory and use them directly.
All features work correctly.

17 changes: 14 additions & 3 deletions src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
}

Expand Down
15 changes: 15 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{

Expand All @@ -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'
Expand All @@ -28,12 +37,18 @@ public function register()
});
}

/**
* {@inheritDoc}
*/
public function provides()
{

return ['jade', 'jade.options'];
}

/**
* {@inheritDoc}
*/
public function boot()
{

Expand Down

0 comments on commit bcb8043

Please sign in to comment.