Introduction
TastyIgniter adds a number of directives and variables to the Blade template engine.
Variables
$this->page |
$this->layout |
$this->theme |
$this->param |
Directives
Directives are a unique feature to Laravel Blade and are wrapped with {{ }}
characters or prefixed with @
character.
@page
The @page
tag renders the contents of a page into a layout template.
@page
@partial
@partial('footer')
@component
@component('cartBox')
@component('cartBox', ['checkStockCheckout' => TRUE])
@partial('cart::cartBox')
@content
@content('welcome.htm')
@partialIf
@partialIf('cartBox')
@hasComponent
@hasSection('navigation')
<div class="pull-right">
@yield('navigation')
</div>
<div class="clearfix"></div>
@endif
@stack
@push('sidebar')
Add this content to the sidebar
@endpush
@stack('sidebar')
@push('scripts')
This will be second...
@endpush
// Later...
@prepend('scripts')
This will be first...
@endprepend
@styles
@styles
function onStart()
{
$this->addCss('assets/css/style.css');
}
@push('styles')
<link rel="stylesheet" href="assets/css/app.css">
@endpush
@scripts
@scripts
function onStart()
{
$this->addJs('assets/js/script.js');
}
@push('scripts')
<script src="assets/js/app.js"></script>
@endpush
@verbatim
Hello, @{{ name }}.
@verbatim
<div class="container">
Hello, {{ name }}.
</div>
@endverbatim
@if
@if (count($categories) === 1)
I have one category!
@elseif (count($categories) > 1)
I have multiple categories!
@else
I don't have any categories!
@endif
@auth
@auth
// The user is authenticated...
@endauth
@guest
// The user is not authenticated...
@endguest
@unless
@unless (Cart::content())
Cart is empty.
@endunless
@for
@for ($i = 0; $i < 10; $i++)
The current value is {{ '{{ $i }}' }}
@endfor
@foreach ($categories as $category)
<p>This is category {{ '{{ $category->name }}' }}</p>
@endforeach
@forelse ($categories as $category)
<li>{{ '{{ $category->name }}' }}</li>
@empty
<p>No categories</p>
@endforelse
@while (true)
<p>I'm looping forever.</p>
@endwhile
@inject
@inject('metrics', 'App\Services\MetricsService')
<div>
Monthly Revenue: {{ '{{ $metrics->monthlyRevenue() }}' }}.
</div>
Unsupported Directives
Directive | Equivalent |
---|---|
@extends |
Use Theme Layouts |
@include |
Use @partial |
@includeIf |
Use @partialIf |
@includeWhen |
Use @partialWhen |
@includeUnless |
Use @partialUnless |
@includeFirst |
Use @partialFirst |
@endcomponent |
Use @component |
@componentfirst |
Use @component |
@endcomponentfirst |
Use @component |