In a Generator, process a layout on a file fragment

I am processing some files with YAML front matter and wish to output the data into a single file. I’ve written a Jekyll::Generator and can write the HTML directly to a file. I’ve written a different generator where I modify front matter data and let the layout process take its course. But can I, with my file fragments, use layout files to format the chunks, then output the results to a single file?

I’m still curious about the above idea, but a simpler solution is to put my data (with a generator) into the front matter of each post as a sequence of mappings
[https://yaml.org/spec/1.2/spec.html#id2759963] (example 2.4)
[https://idratherbewriting.com/documentation-theme-jekyll/mydoc_yaml_tutorial#example-9-conditions]
then, as front matter data a list can be iterated over with Liquid and can be used to populate Included chunks of HTML.