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
itemsIReadOnlyList<T>Source collection. When null or empty, yields an empty Fragment.
keySelectorFunc<T, string>Selector that derives a stable per-item key.
rendererFunc<T, VNode>Function that produces a VNode for each item.
keystringOptional key disambiguating this Fragment from siblings at the same position.
Returns
- FragmentNode
A FragmentNode wrapping the rendered VNodes.
Type Parameters
TElement 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
itemsIReadOnlyList<T>Source collection. When null or empty, yields an empty Fragment.
keySelectorFunc<T, int, string>Selector that derives a stable per-item key from the item and its index.
rendererFunc<T, int, VNode>Function that produces a VNode from the item and its index.
keystringOptional key disambiguating this Fragment from siblings at the same position.
Returns
- FragmentNode
A FragmentNode wrapping the rendered VNodes.
Type Parameters
TElement type of the source collection.