feat: add support for registering block patterns with blade partials as content #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This would close #13
Description
Following on from the discussion in #13, this PR adds support for registering Block Patterns.
A new BlockPatternModule is added and registered with Poet. It then takes config via
config/poet.php
under theblock_pattern
key, and registers the patterns in a similar way to how Blocks are registered.Note: The
namespace()
method from theBlockModule
is also required for Block Patterns. I've moved this method to aHasNamespace
trait, which both theBlockModule
andBlockPatternModule
now use.Docs
Registering a Block Pattern
Poet can also register Block Patterns for you, with an optional Blade view for the content.
Patterns are registered using the
namespace/label
defined when registering the pattern with the editor.If no namespace is provided, the current theme's text domain will be used instead.
Registering a block in most cases is as simple as:
You can register the actual content for the pattern here as well, using the
content
key. Or leave it blank to use a corresponding blade view.Creating a Pattern View
Given the block
sage/fake-paragraph
, if nocontent
key is defined, then your accompanying Blade view would be located atviews/block-patterns/fake-paragraph.blade.php
.This Block Pattern view may look like this: