liberusoftware / module-cms-blocks
Block system and page-builder rendering for Liberu CMS: a registry of block types and a recursive, XSS-safe renderer.
Package info
github.com/liberusoftware/module-cms-blocks
Type:liberu-module
pkg:composer/liberusoftware/module-cms-blocks
Requires
- php: ^8.5
- illuminate/support: ^13.38.0
- liberusoftware/module-cms-contracts: ^0.1
- liberusoftware/module-cms-core: ^0.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-14 19:55:11 UTC
README
Repository
Source, issues, and release history: https://github.com/liberusoftware/module-cms-blocks
Composer package: https://packagist.org/packages/liberusoftware/module-cms-blocks
The block system and page-builder rendering for Liberu CMS: a registry of block types and a recursive, XSS-safe renderer.
Model
A block is a JSON-shaped array:
['type' => 'columns', 'data' => ['columns' => 2], 'children' => [ ['type' => 'heading', 'data' => ['level' => 2, 'text' => 'Hello']], ['type' => 'text', 'data' => ['text' => 'World']], ]]
BlockRenderer (bound to BlockRendererInterface) resolves each block's type
from the BlockTypeRegistry and renders it, recursing into children — the
basis of nested page-builder layouts. An unknown type renders to an empty string
rather than throwing, so removing a block type never breaks a page.
$renderer = app(\Liberu\Cms\Contracts\Block\BlockRendererInterface::class); $html = $renderer->renderMany($page->blocks);
Prebuilt types
text, heading, image, code, cta, and columns (a nesting container).
All output is HTML-escaped — blocks never emit untrusted markup (OWASP A03).
Custom types
Implement BlockTypeInterface (or extend AbstractBlockType) and register it:
app(\Liberu\Cms\Blocks\BlockTypeRegistry::class)->register(new MyBlock);
Public contracts
BlockRendererInterface, BlockTypeInterface (in cms-contracts).
Events
- Emits / Listens: none.