dvResolveDocumentSlots function

Map<DVDocumentSlot, String> dvResolveDocumentSlots(
  1. DVWebDocumentSlots slots, {
  2. String readFile(
    1. String path
    )?,
})

The HTML each slot resolves to: inline snippets as written, file snippets through readFile, in order.

Implementation

Map<DVDocumentSlot, String> dvResolveDocumentSlots(
  DVWebDocumentSlots slots, {
  String Function(String path)? readFile,
}) => <DVDocumentSlot, String>{
  for (final DVDocumentSlot slot in DVDocumentSlot.values)
    slot: <String>[
      for (final DVHtmlSnippet snippet in slots.of(slot))
        snippet.html ??
            (readFile ??
                (String path) => throw ArgumentError.value(path, 'readFile', 'is needed to read a snippet file'))(
              snippet.file!.path,
            ),
    ].join('\n'),
};