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
|
applyTemplate = templateFn: entry: let
|
||||||
template = templateFn (args // entry);
|
template = templateFn (args // entry);
|
||||||
in
|
in
|
||||||
if isBaseTemplate template then {
|
if isBaseTemplate template then
|
||||||
inherit (entry) file;
|
template.output
|
||||||
inherit (template) output;
|
|
||||||
}
|
|
||||||
else let
|
else let
|
||||||
newEntry = template.output // {inherit (entry) file;};
|
newEntry = template.output;
|
||||||
foundTemplateFn = findTemplateFn newEntry;
|
foundTemplateFn = findTemplateFn newEntry;
|
||||||
in
|
in
|
||||||
applyTemplate foundTemplateFn newEntry;
|
applyTemplate foundTemplateFn newEntry;
|
||||||
|
|
||||||
|
applyTemplateFile = templateFn: entry: {
|
||||||
|
inherit (entry) file;
|
||||||
|
output = applyTemplate templateFn entry;
|
||||||
|
};
|
||||||
|
|
||||||
replaceSuffix = from: to: string:
|
replaceSuffix = from: to: string:
|
||||||
if !(hasSuffix from string) then
|
if !(hasSuffix from string) then
|
||||||
abort "invalid suffix `${from}` for string `${string}`"
|
abort "invalid suffix `${from}` for string `${string}`"
|
||||||
|
@ -80,7 +83,7 @@ pkgs: src: {extraArgs, entries, templates}: let
|
||||||
foundTemplateFn = findTemplateFn entry;
|
foundTemplateFn = findTemplateFn entry;
|
||||||
entry = getEntry entryFile;
|
entry = getEntry entryFile;
|
||||||
in
|
in
|
||||||
applyTemplate foundTemplateFn entry;
|
applyTemplateFile foundTemplateFn entry;
|
||||||
|
|
||||||
in /*sh*/''
|
in /*sh*/''
|
||||||
${concatMapStrings
|
${concatMapStrings
|
||||||
|
|
Loading…
Reference in a new issue