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)
|
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):
|
example entries (using the previous example templates):
|
||||||
```nix
|
```nix
|
||||||
_: {
|
_: {
|
||||||
|
|
|
@ -8,6 +8,13 @@ pkgs: src: {extraArgs, entries, templates}: let
|
||||||
inherit (lib.strings) concatMapStrings concatStrings escapeShellArg hasSuffix isString removeSuffix;
|
inherit (lib.strings) concatMapStrings concatStrings escapeShellArg hasSuffix isString removeSuffix;
|
||||||
inherit (lib.trivial) functionArgs;
|
inherit (lib.trivial) functionArgs;
|
||||||
|
|
||||||
|
templates' = templates ++ [
|
||||||
|
({ format, output, ... }: {
|
||||||
|
name = "passthrough";
|
||||||
|
inherit format output;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
args = {inherit pkgs getEntry applyTemplate;}
|
args = {inherit pkgs getEntry applyTemplate;}
|
||||||
// (import ./stdlib.nix pkgs)
|
// (import ./stdlib.nix pkgs)
|
||||||
// extraArgs;
|
// extraArgs;
|
||||||
|
@ -22,7 +29,7 @@ pkgs: src: {extraArgs, entries, templates}: let
|
||||||
in
|
in
|
||||||
template'.name == entry.template)
|
template'.name == entry.template)
|
||||||
null
|
null
|
||||||
templates;
|
templates';
|
||||||
in
|
in
|
||||||
if template == null then
|
if template == null then
|
||||||
abort "unknown template `${entry.template}`"
|
abort "unknown template `${entry.template}`"
|
||||||
|
|
Loading…
Reference in a new issue