Download the PHP package pinkcrab/bladeone-provider without Composer
On this page you can find all versions of the php package pinkcrab/bladeone-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pinkcrab/bladeone-provider
More information about pinkcrab/bladeone-provider
Files in pinkcrab/bladeone-provider
Package bladeone-provider
Short Description An implementation of the PinkCrab Renderable Interface used in the PinkCrab Plugin Framework.
License MIT
Homepage https://pinkcrab.co.uk
Informations about the package bladeone-provider
BladeOne_Provider
A BladeOne Provider for the PinkCrab Renderable Interface.
Supports and tested with the PinkCrab Perique Framework versions 1.4.*
Why?
The BladeOne implementation of the Renderable interface, allows the use of Blade within the PinkCrab Framework.
Setup
`
The simplest way to enable BladeOne is to use the BladeOne_Bootstrap
helper class, this will configure BladeOne fully for use as the Renderable
implementation. To use this just include the following before Perique is setup in your plugin.php file for plugins or functions.php for themes.
\$views_path :: This can be a string or an array of strings. If an array is passed, the first path that exists will be used. If not passed, the path defined in Perique will be used.
\$cache_path :: This should be a string path to the cache directory. If not passed, the path will be set as the
WP_CONTENT_DIR
. 'uploads/compiled/blade'\$blade_mode :: For more details on the options please see official docs
\$blade_class :: This should be a the class name or instance of a class that extends
PinkCrab_BladeOne::class
this allows for the creation of custom components and extending BladeOne in general. For more details please see official docs Passing nothing or an invalid type will just use the default PinkCrab_BladeOne.If the cache directory doesn't exist, BladeOne will create it for you. It is however best to do this yourself to be sure of permissions etc.
Included Components
Out of the box PinkCrab_BladeOne comes with the BladeOneHTML trait added, giving access all HTML components. BladeOneHTML Docs
Configuring BladeOne
At its core BladeOne is a single class representation of Blade and most of its core functionality. To make configuration possible when being injected from DI Container we have a custom class you can extend and add to the registration array like any other Hookable class.
You can have as many of these config classes as you want, allowing you to break up any custom directives, globals values and aliases etc.
Public Methods
The BladeOne_Provider class has a number of methods which can be used to configure the underlying BladeOne implementation. This can be done using the config()
method as part of the Config class above.
allow_pipe
Calling this will allow you toggle piping {{ $var | esc_html }}
on or off. By default this is enabled.
Details: https://github.com/EFTEC/BladeOne/wiki/Template-Pipes-\(Filter)
directive
Calling this will allow you to create custom directives
Details: https://github.com/EFTEC/BladeOne/wiki/Methods-of-the-class#directive
Don't forget our config class is loaded via the DI Container, so you can encapsulate your Directive callbacks into a class, with dependencies injected using the DI Container. (See above example)
directive_rt
Calling this will allow you to create custom directives
add_include
This will allow you to set alias for your templates, this is ideal for global variables (share()).
add_alias_classes
This allows for the creation of simpler and short class names for use in templates.
share
Allows fore the creation of globals variable. This is best set in the Config class (detailed above) as you can pass in dependencies.
You do not need to defined \$GLOBAL_foo when you are passing values to render
\$foo->render('template.path', [])
Details: https://github.com/EFTEC/BladeOne/wiki/Methods-of-the-class#share
set_mode
Allows for the setting of a custom rendering mode. used MODE_AUTO by default.
set_file_extension
Allows you to define a custom extension for your blade templates.
set_compiled_extension
Allows you to define a custom extension for your compiled views.
set_esc
Allows you to define a custom esc function for your views. By default this is set to esc_html
.
Magic Call Methods
The BladeOne class has a large selection of Static and regular methods, these can all be accessed from BladeOne_Provider. These can be called as follows.
For the complete list of methods, please visit https://github.com/EFTEC/BladeOne/wiki/Methods-of-the-class
If you want access none static methods using a static means, you can use
calling
engine()
on view, will return the underlying rendering engine used, in this case the BladeOne_Provider.Of course you can set the engine it self as a global variable using
$provider->share('view_helper', [App::view(), 'engine'])
. Then you can use{$view_helper->some_method(\$data)}
in your view.
View Models
Inside your templates it is possible to render viewModels in your templates by using either of the following methods.
Components
Inside your templates it is possible to render components in your templates by using either of the following methods.
Please note
@component
is not the same as regular BLADE components. BladeOne does not support these and this is the Perique Frameworks own implementation.
Dependencies
Requires
License
MIT License
http://www.opensource.org/licenses/mit-license.html
Previous Perique Support
- For support of Perique 1.3.* please use BladeOne_Provider 1.3.*
- For support of all versions from 0.5.* - 1.1.* please use BladeOne_Provider 1.2.*
- For support of the initial PinkCrab Plugin Frameworks (version 0.2.* -> 0.4.*) please use BladeOne_Provider 1.0.3
Change Log
- 1.4.1 - Fix issue where paths are not correctly assumed if not passed via Bootstrap::use()
- 1.4.0 - Now matches the changes in Perique 1.4.0, no longer compatible with Perique 1.3.0 and below.
- 1.3.2 - Updated to match Perique 1.3.0 with both Component and View_Model support. Dropped PHP 7.1 support.
- 1.3.1 - Adds in direct support from $this->component() and $this->view_models() in views, inline with native
PHP_Engine
renderer. - 1.3.0 - Updated to match Perique 1.2.0 with both Component and View_Model support. Dropped PHP 7.1 support.
- 1.2.2 - Ensure that BladeOne is only loaded once wp is loaded. This avoids issues where template globals are registered before WP has finished loading. See issue #13
- 1.2.1 - Updated Readme and bumped BladeOne and BladeOneHTMl to the latest versions, now only compatible with Perique 1.*.*
- 1.2.0 - Comes with bootloader and ability to configure internal blade instance and use custom implementations to add directives, components and config in general
- 1.1.1 - Updated composer.json to support Perique 1.* and set github to run actions on PR & Merge to Dev
- 1.1.0 - Moved to the new Perique naming.
- 1.0.3 - Included the HTML extension by default.
- 1.0.2 - Bumped internal support for version 0.4.* of the Plugin Framework
All versions of bladeone-provider with dependencies
pinkcrab/perique-framework-core Version 1.4.0
eftec/bladeone Version 4.*
eftec/bladeonehtml Version 2.*