add passthrough built-in template
This commit is contained in:
parent
e7543840b0
commit
93984819ff
2 changed files with 12 additions and 1 deletions
|
@ -177,6 +177,10 @@ a template that's inherited from a different template also inherits its format -
|
|||
|
||||
an entry can take an arbitrary number of arguments and returns `{ template, ... }`, the `...` being the desired template's arguments (sans `extraArgs`, those are passed either way)
|
||||
|
||||
there's a built-in `passthrough` template, which (as the name might suggest) takes in a `format` and `output` and passes them through to the template with no changes
|
||||
|
||||
this is useful if you're using nte to create a single file - you won't have to create a boilerplate template
|
||||
|
||||
example entries (using the previous example templates):
|
||||
```nix
|
||||
_: {
|
||||
|
|
|
@ -8,6 +8,13 @@ pkgs: src: {extraArgs, entries, templates}: let
|
|||
inherit (lib.strings) concatMapStrings concatStrings escapeShellArg hasSuffix isString removeSuffix;
|
||||
inherit (lib.trivial) functionArgs;
|
||||
|
||||
templates' = templates ++ [
|
||||
({ format, output, ... }: {
|
||||
name = "passthrough";
|
||||
inherit format output;
|
||||
})
|
||||
];
|
||||
|
||||
args = {inherit pkgs getEntry applyTemplate;}
|
||||
// (import ./stdlib.nix pkgs)
|
||||
// extraArgs;
|
||||
|
@ -22,7 +29,7 @@ pkgs: src: {extraArgs, entries, templates}: let
|
|||
in
|
||||
template'.name == entry.template)
|
||||
null
|
||||
templates;
|
||||
templates';
|
||||
in
|
||||
if template == null then
|
||||
abort "unknown template `${entry.template}`"
|
||||
|
|
Loading…
Reference in a new issue