Skip to content

Aurora 1.0 is out!

What's new →
Docs menu

Building a site

Block views and helpers

Render text, links, images and slots with helpers or Blade directives.

A block's view is an anonymous Blade component. It receives the block's $data:

resources/views/components/blocks/card.blade.php Blade
@props(['data' => []])

<a href="{{ link_href($data) }}" class="card">
    <x-aurora::media :value="$data['image'] ?? null" size="md" class="card-image" />
    <h3 @editable('title')>{{ inline_text($data['title'] ?? '') }}</h3>
    @if (shows_field('body', $data['body'] ?? null))
        <p @editable('body')>{{ plain_text($data['body'] ?? '') }}</p>
    @endif
</a>

The helpers

The helpers are short forms of static methods (inline_text() is Aurora\Support\Markup::inline()), so views need no @php use … imports. Call the classes directly when you prefer.

HelperWhat it does
@editable('field')Makes the element editable on the canvas (for fields listed in editables())
inline_text($text)Text with *highlighted* words
plain_text($text)Plain text, escaped
rich_text($html)Rich text from a RichEditor, cleaned
shows_field($field, $value)Whether to render an optional field: when it's filled, or when the canvas is editing so it can be filled
link_href($data), link_target($data)The address and target of a Fields::link() group; pass the prefix for another group: link_href($data, 'cta')
is_editing()True on the canvas, for example to show placeholders
block_slot($name)A container block's slot with the blocks in it
<x-aurora::media>A media library image, responsive, with the block's crop and the focal point

Or as Blade directives

HelperDirective
{{ inline_text($data['title'] ?? '') }}@inlineText($data['title'] ?? '')
{{ plain_text(…) }}, {{ rich_text(…) }}@plainText(…), @richText(…)
{{ link_href($data) }}, {{ link_target($data) }}@linkHref($data), @linkTarget($data)
{{ block_slot('content') }}@blockSlot('content') (not @slot: Blade's components use it)
@if (shows_field('body', …)) … @endif@shows('body', …) … @endshows
@if (is_editing()) … @endif@editing … @else … @endediting

Named so they never clash

The helpers are named for what they read (link_href, plain_text), never bare words like href() or text() that Laravel or another package could also define.