Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Twill Laravel Package

area17/twill

Twill is an open-source Laravel package for building a custom CMS fast. It provides a polished admin UI with prebuilt features and Vue components, stays flexible and extensible, works headless or integrated, and lets you use your own models with no lock-in.

View on GitHub
Deep Wiki
Context7

Nested blocks

Since Twill 3.x it is possible to nest blocks. In theory to infinity.

To make this work you can add one or more block editors to your block.

However, you have to specify their names

:::filename::: resources/views/twill/blocks/nested-block.blade.php :::#filename:::

[@twillBlockTitle](https://github.com/twillBlockTitle)('Nested Block left right')
[@twillBlockIcon](https://github.com/twillBlockIcon)('text')
[@twillBlockGroup](https://github.com/twillBlockGroup)('app')

<x-twill::input
    name="title"
    label="Title"
    :translated="true"
/>

<x-twill::block-editor name="left"/> <!-- [tl! focus] -->
<x-twill::block-editor name="right"/> <!-- [tl! focus] -->

With the example above we now have 2 editors. One is named left and the other right.

Now, let's move over to the rendering aspect.

Basic usage

Following the documentation of block editors we know already how to render a block.

:::filename::: resources/views/site/blocks/nested-block.blade.php :::#filename:::

[@php](https://github.com/php)
    /** [@var](https://github.com/var) \A17\Twill\Services\Blocks\RenderData $renderData */
[@endphp](https://github.com/endphp)
<div style="width: 100%">
    <div style="width: 50%; float: left;">
        Left
        {!! $renderData->renderChildren('left') !!}
    </div>
    <div style="width: 50%; float: left;">
        Right
        {!! $renderData->renderChildren('right') !!}
    </div>
</div>

$renderData is new in Twill 3.x, it is a nested representation of the data to be rendered.

Manually rendering

By default, the solution above will render all the children next to each other. But if you wish to wrap the children each in their own container you can use the getChildrenFor method on the $renderData

[@php](https://github.com/php)
    /** [@var](https://github.com/var) \A17\Twill\Services\Blocks\RenderData $renderData */
[@endphp](https://github.com/endphp)
<div style="width: 100%">
    <div style="width: 50%; float: left;">
        Left

        [@foreach](https://github.com/foreach)($renderData->getChildrenFor('left') as $leftBlock)
            <div style="background-color: green; padding: 150px;">
                {!! $leftBlock !!}
            </div>
        [@endforeach](https://github.com/endforeach)
    </div>
    <div style="width: 50%; float: left;">
        Right

        [@foreach](https://github.com/foreach)($renderData->getChildrenFor('right') as $rightBlock)
            <div style="background-color: orange; padding: 150px;">
                {!! $rightBlock !!}
            </div>
        [@endforeach](https://github.com/endforeach)
    </div>
</div>
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport