Apologies for being persistent.
I believe this does not really involve much work to implement but gives a lot of benefit in writing out resource files, manifest files and other site related metafiles.
In the frontmatter can have the file name to save to like <out_file_name>.<ext>
and the template name to use like <the_template_file_name>.<ext>
. E.g. <dummy_file_name>.md
can have:
+++
target_file = "<out_file_name>.<ext>"
template_file = "<the_template_file_name>.<ext>"
+++
or
+++
target_file = "<out_file_name>.<ext>"
template_file = this_file_content
+++
The above template may return the target_file
if needed for hashing or any other output.
In this case process, the frontmatter of <dummy_file_name>.md
as with any other file and then pass it to be processed as by <the_template_file_name>.<ext>
as any other template and finally write out the output to <out_file_name>.<ext>
.
Alternatively, for site level files this can be specified in the configuration.
For resource processing, it would be nice to have something like execute_as_template(<output_file_or_string_as_a_file>, <template_file_or_string_as_a_file>, <optional_file_or_string_as_a_file_with_frontmatter_and_content>)
which would return the link to the template output. This can be used as a link and also can be used for fingerprinting. This is not necessary but nice to have as long as there is a way to fingerprint the output of a template using the above methods, i.e., templates calling get_file_hash
with the output file needs to be processed after the files are written. Most convenient would be to have both as then if are hashing is needed one can call execute_as_template
.
The page variables ideally should be able to access the following within the template <output>
, <optional_with_frontmatter_and_content>
, <template>
in all the cases. The <output>
could be pipped into sass processing.