add applyTemplateFile
applyTemplate now returns the output alone and that's the version passed to all entries and shit this allows a user (krizej) to do inline templates
This commit is contained in:
parent
592db7009f
commit
e7543840b0
1 changed files with 9 additions and 6 deletions
15
engine.nix
15
engine.nix
|
@ -32,16 +32,19 @@ pkgs: src: {extraArgs, entries, templates}: let
|
|||
applyTemplate = templateFn: entry: let
|
||||
template = templateFn (args // entry);
|
||||
in
|
||||
if isBaseTemplate template then {
|
||||
inherit (entry) file;
|
||||
inherit (template) output;
|
||||
}
|
||||
if isBaseTemplate template then
|
||||
template.output
|
||||
else let
|
||||
newEntry = template.output // {inherit (entry) file;};
|
||||
newEntry = template.output;
|
||||
foundTemplateFn = findTemplateFn newEntry;
|
||||
in
|
||||
applyTemplate foundTemplateFn newEntry;
|
||||
|
||||
applyTemplateFile = templateFn: entry: {
|
||||
inherit (entry) file;
|
||||
output = applyTemplate templateFn entry;
|
||||
};
|
||||
|
||||
replaceSuffix = from: to: string:
|
||||
if !(hasSuffix from string) then
|
||||
abort "invalid suffix `${from}` for string `${string}`"
|
||||
|
@ -80,7 +83,7 @@ pkgs: src: {extraArgs, entries, templates}: let
|
|||
foundTemplateFn = findTemplateFn entry;
|
||||
entry = getEntry entryFile;
|
||||
in
|
||||
applyTemplate foundTemplateFn entry;
|
||||
applyTemplateFile foundTemplateFn entry;
|
||||
|
||||
in /*sh*/''
|
||||
${concatMapStrings
|
||||
|
|
Loading…
Reference in a new issue