Shared frontmatter-inject:-to-GgenIgniter.Actuate.inject_content!/5
conversion logic, extracted so Mix.Tasks.GgenIgniter.Sync (the original,
standalone pipeline) and GgenIgniter.Reactors.ReconcileReactor (the
opt-in Reactor pipeline) share exactly ONE real implementation instead of
two independently-drifting copies -- see this module's functions'
individual docs for the full mapping table (originally authored inline in
Mix.Tasks.GgenIgniter.Sync, moved here verbatim, behavior unchanged).
Two real entry points:
resolve_injection!/1-- converts aGgenIgniter.Frontmatter.t()'sinject:/before:/after:/at_line:fields into{marker, insert_mode, insert_opts},Actuate.inject_content!/5's realmarker/insert_mode/optsargs (minuspath/content, which are call-site-specific). Requires exactly one ofbefore:/after:/at_line:-- zero or more than one raises a clear, namedArgumentError(a template-authoring error, never a silent pick).strip_single_trailing_newline/1-- strips exactly one trailing"\n"from a rendered injection body before it reachesActuate.inject_content!/5, which otherwise splices in one real extra blank line (mirrorsActuate's own trailing-newline handling for the TARGET file's lines).
Summary
Functions
Converts a template's inject:/before:/after:/at_line: frontmatter
fields into Actuate.inject_content!/5's real args
({marker, insert_mode, insert_opts}). Exactly one anchor is required --
before OR after OR at_line, never zero, never more than one.
A rendered template body ends in a trailing "\n" as a plain
file-formatting convention -- but Actuate.inject_content!/5 itself does
String.split(content, "\n") un-trimmed, so an un-stripped trailing
"\n" would splice in one real extra blank line at the end of the
injected block. Strips exactly one trailing "\n" (mirroring
Actuate's own drop_trailing_empty/1 for the TARGET file's lines),
without guessing at or discarding any blank lines the template author put
there deliberately (a second trailing blank line in the template body is
left fully intact).
Functions
@spec resolve_injection!(GgenIgniter.Frontmatter.t()) :: {String.t() | Regex.t() | nil, :before | :after | :at_line, keyword()}
Converts a template's inject:/before:/after:/at_line: frontmatter
fields into Actuate.inject_content!/5's real args
({marker, insert_mode, insert_opts}). Exactly one anchor is required --
before OR after OR at_line, never zero, never more than one.
A rendered template body ends in a trailing "\n" as a plain
file-formatting convention -- but Actuate.inject_content!/5 itself does
String.split(content, "\n") un-trimmed, so an un-stripped trailing
"\n" would splice in one real extra blank line at the end of the
injected block. Strips exactly one trailing "\n" (mirroring
Actuate's own drop_trailing_empty/1 for the TARGET file's lines),
without guessing at or discarding any blank lines the template author put
there deliberately (a second trailing blank line in the template body is
left fully intact).