Skip to main content

Overview

Lyger includes a lightweight Blade-inspired templating engine for rendering dynamic views. The Blade engine provides a clean syntax for working with PHP templates, layouts, and components.
Lyger’s Blade implementation (Lyger\Livewire\Blade) is a simplified version designed for performance and ease of use.

Basic Usage

Setting Up Blade

Configure the views and cache paths:

Rendering Views

Template Files

Create template files in your views directory:

Variable Extraction

All data passed to the view is automatically extracted as variables:

Includes and Partials

Including Partials

Use Blade::include() to include partial views:

Layouts and Sections

Defining Layouts

Create a layout template with yield points:

Extending Layouts

1

Extend Layout

Use Blade::extends() to specify the parent layout:
2

Define Sections

Use Blade::start() and Blade::end() to define section content:

Complete Layout Example

Components

Rendering Components

Use Blade::component() to render Livewire or component class instances:

Component in Views

Loop Helper

The Blade::each() method simplifies rendering lists:

Loop Variables

The $loop variable provides useful iteration data:

Blade Directives

The Lyger\Livewire\Directives class provides common template directives:

Conditional Directives

Loop Directives

Authentication Directives

Switch Directive

Shared Data

Share data across all views:

Error Handling

Blade automatically handles template errors:

Integration with Livewire

Use Blade to render Livewire component views:

Best Practices

1

Organize Views

Use a consistent directory structure:
2

Escape Output

Always escape user-generated content to prevent XSS:
3

Keep Logic Minimal

Avoid complex business logic in templates. Use controllers or components for data processing.
4

Reuse Partials

Extract repeated markup into partials for better maintainability.
5

Use Dot Notation

Organize views in subdirectories and use dot notation for cleaner code:

Practical Examples

Complete Page Example

API Reference

Blade Class

View Class

Directives Class