Skip to content

Objects & Allow Lists ​

@renderObject declares what a block of DOM may do. Its name is also the state namespace.

Syntax ​

blade
@renderObject('customerPanel', ['render', 'state:read', 'state:write'])

Output:

html
data-render-blade-object="customerPanel" data-render-allow="render state:read state:write"
ActionAllows
renderdata-cg-event="renderBlade", data-render-auto
state:readdata-state-text / -show / -class / -is / -is-class
state:writedata-state-bind / -set / -toggle / -init

An empty name or a misspelled action makes PHP throw InvalidArgumentException, so typos are caught during development.

How a check is decided ​

  • The nearest ancestor decides; nothing is inherited. If an inner object lacks state:write, it's refused even if an outer one has it.
  • Crosses shadow roots. Fragments in isolated mode live in shadow DOM; at the boundary the search jumps to the host.
  • Refusals never throw. Always a console.warn and the action doesn't run. One missing attribute won't take the page down.

It is not a security mechanism ​

Users can of course add attributes in DevTools. @renderObject is valuable because:

  1. The template is the truth: read the Blade and you know what the block can do, without tracing JS.
  2. It catches slips: a read-only block without state:write shows mistakes in the console.

The real gatekeeping is always on the server.

Least privilege ​

blade
{{-- Read-only summary card: state:read only --}}
<aside @renderObject('summary', ['state:read'])>
    <span data-state-text="@cartCount">0</span>
</aside>

{{-- Filter panel: needs to write and trigger re-renders --}}
<section @renderObject('filters', ['render', 'state:read', 'state:write'])>
    ...
</section>

The same template twice ​

blade
<section @renderObject('calcA', ['render', 'state:read', 'state:write'])>@include('partials.calculator')</section>
<section @renderObject('calcB', ['render', 'state:read', 'state:write'])>@include('partials.calculator')</section>

Not a single key in the template changes. calcA:display and calcB:display are independent values.