code16/laravel-content-renderer
Laravel package for rendering content blocks into HTML in a structured, extensible way. Define renderers for different content types, map data to views, and compose pages from reusable components—useful for CMS-like content, editors, and APIs.
Install via Composer: composer require code16/laravel-content-renderer. The package exposes a Blade component @content for rendering structured content (e.g., JSON or arrays) as HTML. Begin by defining simple content blocks as associative arrays (e.g., ['type' => 'text', 'text' => 'Hello']), then render them in Blade with @content($content, 'default'). Start with the included block types (like text, heading) to verify basic functionality before customizing.
Page::jsonContent column), then render via @content($content, 'context').BaseBlockRenderer for custom blocks (e.g., CardRenderer) and bind them in a service provider using ContentRenderer::registerBlockType('card', CardRenderer::class).'hero', 'sidebar') to @content() to reuse the same content structure with different styling/behavior—e.g., @content($blocks, 'hero') vs. @content($blocks, 'card').code16/laravel-form-builder to build WYSIWYG-style content editors—save structured output as JSON and leverage the same renderer for display.type key—'Text' won’t match 'text'. Always normalize types before saving or rendering.ContentRenderer::debug(true) in development to log unhandled types.renderContent() and wrap output with e() or use Blade’s {{ }} inside your renderer’s view.null or malformed JSON. Always validate or default content (e.g., @content($content ?? [], 'default')).CONTENT_RENDERER_DEBUG=true in .env or call ContentRenderer::debug() in your service provider to enable verbose logging of rendering steps.How can I help you explore Laravel packages today?