API / Minn\Blocks / Serializer

Serializer final class

Minn\Blocks\Serializer · public/minn/src/Minn/Blocks/Serializer.php · 69 lines

Parsed blocks back to markup. A core block is written by its short name; attributes are JSON with every character that could end the comment or open a tag spelled as an escape ("<" "<", "--" "--", a backslash "\"), so a value can never break out of its delimiter.

Uses 2

Public

staticblocks(array $blocks): string#

A list of parsed blocks back to markup, freeform runs as written.

$blockslist<Block>
staticblock(Minn\Blocks\Block $block): string#

One block with its inner blocks, as the delimiter comments the parser reads.

staticdelimited(?string $name, array $attrs, string $content): string#

Content wrapped in a block's delimiters; a block with no content is written self-closing.

staticattributes(array $attrs): string#

Block attributes as the delimiter carries them.

staticspreadInnerContent(array $innerContent, array $counts): array#

A parsed block's inner content with each inner block's place (a null) taken as many times as that block became blocks, as a pattern that expands does; one that became none keeps its place.

$innerContentlist<string|null>
$countslist<int>how many blocks each inner block became, in order
@return list<string|null>