Table of Contents

Method ListFragment

Namespace
Velvet
Assembly
Velvet.Docs.dll

ListFragment<T>(IReadOnlyList<T>, Func<T, string>, Func<T, VNode>, string?)

Sibling-friendly variant of List<T>(IReadOnlyList<T>, Func<T, string>, Func<T, VNode>) that wraps the mapped nodes in a single FragmentNode. Because a Fragment is a VNode that the reconciler expands inline, the result can sit among sibling nodes in one children list (e.g. V.Div("c", header, V.ListFragment(...), footer)) without an extra wrapper element.

public static FragmentNode ListFragment<T>(IReadOnlyList<T> items, Func<T, string> keySelector, Func<T, VNode> renderer, string? key = null)

Parameters

items IReadOnlyList<T>

Source collection. When null or empty, yields an empty Fragment.

keySelector Func<T, string>

Selector that derives a stable per-item key.

renderer Func<T, VNode>

Function that produces a VNode for each item.

key string

Optional key disambiguating this Fragment from siblings at the same position.

Returns

FragmentNode

A FragmentNode wrapping the rendered VNodes.

Type Parameters

T

Element type of the source collection.

ListFragment<T>(IReadOnlyList<T>, Func<T, int, string>, Func<T, int, VNode>, string?)

Sibling-friendly variant of List<T>(IReadOnlyList<T>, Func<T, int, string>, Func<T, int, VNode>) that wraps the mapped nodes in a single FragmentNode so the result can sit inline among sibling nodes in one children list.

public static FragmentNode ListFragment<T>(IReadOnlyList<T> items, Func<T, int, string> keySelector, Func<T, int, VNode> renderer, string? key = null)

Parameters

items IReadOnlyList<T>

Source collection. When null or empty, yields an empty Fragment.

keySelector Func<T, int, string>

Selector that derives a stable per-item key from the item and its index.

renderer Func<T, int, VNode>

Function that produces a VNode from the item and its index.

key string

Optional key disambiguating this Fragment from siblings at the same position.

Returns

FragmentNode

A FragmentNode wrapping the rendered VNodes.

Type Parameters

T

Element type of the source collection.