Download the PHP package hex-digital/sage-blade-block-renderer without Composer

On this page you can find all versions of the php package hex-digital/sage-blade-block-renderer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sage-blade-block-renderer

Sage: Blade Block Renderer

Latest Stable Version Total Downloads Build Status

The Blade Block Renderer for Sage allows the easy registration of blade partials for the render function of native Gutenberg blocks.
Useful when you want to edit a block in React, but render with Blade.

Features

Requirements

Installation

Install via Composer:

Usage

Create your native block

Create your Gutenberg block as you normally would, with one small change.

Instead of adding HTML to the save function of your block, instead define it as one of the following:

And that's it! When your block is saved, Gutenberg will save the settings to the database. When it comes time to render your block, the settings will be given to the Blade Block Renderer, and your blade template will be used, along with any attributes, classNames or Inner Blocks given.

If you prefer to use Blade for both the edit and save HTML, you would benefit from using Log1x's ACF Composer package instead. This similarly provides Blade support for blocks, but utilises ACF's Blocks instead, which will be much more powerful.

Rendering a Block with a blade-powered render callback

To create your first rendered block, start by running the following generator command from your theme directory:

This will create app/BladeBlocks/Example.php which is where you will create and manage your first blade block:

You'll see it has a familiar with() function for passing data to your block. However, it is also given the block object as the first parameter.

This allows you to get any attribute, setting or content from the block, as required.

For example, $block->content will give the Inner Blocks content, and $block->image_id would give the value of an attribute called image_id that was defined on the block in JavaScript.

A View is also generated in the resources/views/blocks directory:

The $content variable will contain the HTML for any InnerBlocks added in the editor.
The $blockClass variable will contain the base class for the block, for use with BEM class naming.
This is in the form "wp-block-$prefix-$slug" E.G. wp-block-hex-page-header.
These can then be outputted as required into the blade partial.

All block data is available on the $block object, which is the same as that passed to the BladeBlock with() function. All data returned from the with() function is also available.

Block Preview View

In the view file, you can use $block->preview for conditionally modifying your block when shown in the editor.

You can also load a different blade partial by duplicating your existing view and prefixing it with preview- (e.g. preview-example.blade.php).

However, if you're using the blade partial for both the edit and save HTML, you would benefit from using Log1x's ACF Composer package instead. This similarly provides Blade support for blocks, but utilises ACF's Blocks instead, which will be much more powerful.

Modifying your Block

Your Block has a few options available to it to modify. Add these as member variables to your generated block class to define and use them.

Your block's class will default to "wp-block-$prefix-$slug", where the prefix has the trailing slash trimmed. This block class is available in the view as $blockClass for easy use with BEM class naming.

Bug Reports

If you discover a bug in Sage Blade Block Renderer, please open an issue.

Contributing

Contributing, whether through PRs, reporting an issue, or suggesting an idea, is encouraged and extremely appreciated.

License

We provide the Sage Blade Block Renderer under the MIT License.


All versions of sage-blade-block-renderer with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hex-digital/sage-blade-block-renderer contains the following files

Loading the files please wait ....