Skip to content

unikapps/BladeView

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BladeView

Laravel's Blade template engine in CakePHP 3.

Install

Composer:

    [
        "require": {
            "dowilcox/blade-view": "0.2.*"
        }
    ]

In your bootstrap.php:

Plugin::load('BladeView', ['bootstrap' => false]);

In your controller:

public $viewClass = '\Dowilcox\BladeView\View\BladeView';

Now change all the template files in src/Template from .ctp to .blade.php

Usage

See Laravel's documenation for Blade: http://laravel.com/docs/4.2/templates.

CakePHP view functions and helpers work a bit different.

###Variables Before:

<?php echo h($variable); ?>

After:

{{{ $variable }}}

###View functions: Before:

<?php echo $this->fetch(); ?>

After:

@fetch()

###Helpers (if loaded in a controller): Before:

<?php echo $this->Html->css(); ?>

After:

@html->css()

More Examples

{{-- src/Template/Common/view.blade.php --}}
<h1>@fetch('title')</h1>
@fetch('content')

<div class="actions">
    <h3>Related actions</h3>
    <ul>
    @fetch('sidebar')
    </ul>
</div>
{{-- src/Template/Posts/view.blade.php --}}
@extend('/Common/view')

@assign('title', $post)

@start('sidebar')
<li>
    @html->link('edit', [
        'action' => 'edit',
        $post['Post']['id']
    ])
</li>
@end()

{{-- The remaining content will be available as the 'content' block --}}
{{-- In the parent view. --}}
{{{ $post['Post']['body'] }}}

About

Laravel's Blade template engine in CakePHP 3.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%