All Projects → fiskhandlarn → blade

fiskhandlarn / blade

Licence: GPL-3.0 license
🏃 A library for using Laravel Blade templates in WordPlate.

Programming Languages

PHP
23972 projects - #3 most used programming language
Blade
752 projects

Projects that are alternatives of or similar to blade

laravel-simple-select
Laravel Simple Select inputs component for Blade and Livewire.
Stars: ✭ 59 (+110.71%)
Mutual labels:  blade, blade-template
render react
Pre-render and mount React components from Ruby
Stars: ✭ 14 (-50%)
Mutual labels:  view, render
edge
[READ ONLY] A Blade compatible template engine with much extendable interface.
Stars: ✭ 26 (-7.14%)
Mutual labels:  blade, blade-template
kirby-blade
Enable Blade for Kirby 3
Stars: ✭ 14 (-50%)
Mutual labels:  blade, blade-template
Laravel Blade Javascript
A Blade directive to export variables to JavaScript
Stars: ✭ 485 (+1632.14%)
Mutual labels:  view, blade
echo-template
golang template for echo framework!
Stars: ✭ 39 (+39.29%)
Mutual labels:  view, render
laravel-blade-phpstorm-live-template
PhpStorm Live Templates for Laravel Templates (Blade)
Stars: ✭ 32 (+14.29%)
Mutual labels:  blade, blade-template
Blade
🔪 A standalone version of Laravel's Blade templating engine for use outside of Laravel.
Stars: ✭ 542 (+1835.71%)
Mutual labels:  view, blade
Wpemerge
A modern, MVC-powered WordPress as a CMS workflow. 🚀
Stars: ✭ 348 (+1142.86%)
Mutual labels:  view, blade
kirby-blade
Enable Laravel Blade Template Engine for Kirby 3
Stars: ✭ 20 (-28.57%)
Mutual labels:  view, blade
Laravel Blade X
Use custom HTML components in your Blade views
Stars: ✭ 538 (+1821.43%)
Mutual labels:  view, blade
Gin Template
golang template for gin framework!
Stars: ✭ 106 (+278.57%)
Mutual labels:  view, render
bottomsheets
Material Bottom Sheets library for Android
Stars: ✭ 76 (+171.43%)
Mutual labels:  view
wordplate.github.io
The salt keys generator for environment files
Stars: ✭ 19 (-32.14%)
Mutual labels:  wordplate
x-blade-components
Laravel Blade Components ready to use
Stars: ✭ 36 (+28.57%)
Mutual labels:  blade
ShadowStackView
Create something like Shadow-View animation when drag the view on screen
Stars: ✭ 25 (-10.71%)
Mutual labels:  view
Panda
Create view hierarchies declaratively.
Stars: ✭ 69 (+146.43%)
Mutual labels:  view
MultiModal
Use multiple .sheet, .alert, etc. modifiers in the same SwiftUI View
Stars: ✭ 49 (+75%)
Mutual labels:  view
VF-BlenderAutoSaveRender
Automatically saves a numbered or dated image after every render and can extend the Blender output path with dynamic variables
Stars: ✭ 34 (+21.43%)
Mutual labels:  render
andColorPicker
Color picker library for Android
Stars: ✭ 233 (+732.14%)
Mutual labels:  view

blade

blade

A library for using Laravel Blade templates in WordPress/WordPlate.

Build Status Coverage Status Total Downloads Latest Version License

Installation

Require this package, with Composer, in the root directory of your project.

$ composer require fiskhandlarn/blade

Usage

Render

Use helper function blade:

blade('index', ['machine' => 'Voight-Kampff']);

(This renders and echoes the template /resources/views/index.blade.php and caches it to /storage/views.)

... or instantiate Blade by passing the folder(s) where your view files are located, and a cache folder. Render a template by calling the render method.

use Fiskhandlarn\Blade;

$blade = new Blade(get_stylesheet_directory() . '/views', get_stylesheet_directory() . '/cache');

echo $blade->render('index', ['machine' => 'Voight-Kampff']);

Render with data from a controller class

Use helper function blade_controller:

blade_controller('index', 'Index');

(This renders and echoes the template /resources/views/index.blade.php with data generated from App\Controllers\Index.)

Controller classes must extend Fiskhandlarn\BladeController.

... or use the renderController method on a Blade object:

echo $blade->renderController('index', 'Index');

You can also pass additional data (this won't override properties from the controller though):

blade_controller('index', 'Index', ['lifespan' => "A coding sequence cannot be revised once it's been established."]);
echo $blade->renderController('index', 'Index', ['lifespan' => "A coding sequence cannot be revised once it's been established."]);

See soberwp/controller for more info on how to use controllers.

Supported features:

Unsupported features:

Untested features:

Unnecessary features:

Custom directive

Create a custom directive with helper function blade_directive:

blade_directive('datetime', function ($expression) {
    return "<?php echo with({$expression})->format('Y-m-d H:i:s'); ?>";
});

... or use the directive method on a Blade object:

$blade->directive('datetime', function ($expression) {
    return "<?php echo with({$expression})->format('Y-m-d H:i:s'); ?>";
});

Then you can use the directive in your templates:

{{-- In your Blade template --}}
@php $dateObj = new DateTime('2019-11-01 00:02:42') @endphp
@datetime($dateObj)

Custom composer

Create a custom composer with helper function blade_composer:

// Make variable available in all views
blade_composer('*', function ($view) {
    $view->with(['badge' => 'B26354']);
});

... or use the composer method on a Blade object:

// Make variable available in all views
$blade->composer('*', function ($view) {
    $view->with(['badge' => 'B26354']);
});

Share variables

Share variables across all templates with helper function blade_share:

// Make variable available in all views
blade_share(['badge' => 'B26354']);

... or use the share method on a Blade object:

$blade->share(['badge' => 'B26354']);

Extension

The Blade class passes all method calls to the internal compiler (see documentation) or view factory (see documentation for info on exists, first and creator).

Cache

If WP_DEBUG is set to true templates will always be rendered and updated.

Multisite

If run on a WordPress Multisite the cached files will be separated in subfolders by each site's blog id.

Filters

Use the blade/view/paths filter to customize the base paths where your templates are stored. (Default value is /resources/views.)

add_filter('blade/view/paths', function ($paths) {
    $paths = (array) $paths;

    $paths[] = get_stylesheet_directory() . '/views';

    return $paths;
});

Use the blade/cache/path filter to customize the cache folder path. (Default value is /storage/views.)

add_filter('blade/cache/path', function ($path) {
    $uploadDir = wp_upload_dir();
    return $uploadDir['basedir'] . '/.bladecache/';
});

Use the blade/cache/path filter to control creation of cache folder. (Default value is true.)

add_filter('blade/cache/create', '__return_false');

Use the blade/controller/namespace filter to customize the controller namespace. (Default value is App\Controllers.)

add_filter('blade/controller/namespace', function () {
    return 'MyApp\Controllers';
});

License

GNU GPL 3.0+

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].