mirror of
https://gitlab.com/TECHNOFAB/soonix.git
synced 2026-02-02 15:25:05 +01:00
Compare commits
2 commits
16fbe4d684
...
46abe3729b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46abe3729b | ||
|
|
404d8cb782 |
6 changed files with 26 additions and 1 deletions
|
|
@ -55,6 +55,7 @@ use the `devshellModule` for easy integration, see the docs for more.
|
||||||
- **`derivation`**: Use existing Nix derivations as file content
|
- **`derivation`**: Use existing Nix derivations as file content
|
||||||
- **`gotmpl`**: Advanced Go template rendering via gomplate
|
- **`gotmpl`**: Advanced Go template rendering via gomplate
|
||||||
- **`jinja`**: Python Jinja2 template rendering
|
- **`jinja`**: Python Jinja2 template rendering
|
||||||
|
- **`mustache`**: Mustache template rendering
|
||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ Soonix helps you:
|
||||||
- **derivation**: Use existing Nix derivations as file content
|
- **derivation**: Use existing Nix derivations as file content
|
||||||
- **gotmpl**: Advanced Go template rendering via gomplate
|
- **gotmpl**: Advanced Go template rendering via gomplate
|
||||||
- **jinja**: Python Jinja2 template rendering
|
- **jinja**: Python Jinja2 template rendering
|
||||||
|
- **mustache**: Mustache template rendering
|
||||||
|
|
||||||
### Automatic File Management
|
### Automatic File Management
|
||||||
|
|
||||||
|
|
|
||||||
13
lib/lib.nix
13
lib/lib.nix
|
|
@ -100,6 +100,19 @@
|
||||||
} ''
|
} ''
|
||||||
python ${renderScript} > $out
|
python ${renderScript} > $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
mustache = {
|
||||||
|
name,
|
||||||
|
opts,
|
||||||
|
data,
|
||||||
|
}: let
|
||||||
|
inherit (opts) template;
|
||||||
|
mustache = opts.mustache or pkgs.mustache-go;
|
||||||
|
dataJson = writeText "template-data.json" (builtins.toJSON data);
|
||||||
|
in
|
||||||
|
runCommand name {
|
||||||
|
buildInputs = [mustache];
|
||||||
|
} "mustache ${dataJson} ${template} > $out";
|
||||||
};
|
};
|
||||||
|
|
||||||
buildAllFiles = files:
|
buildAllFiles = files:
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
generator = mkOption {
|
generator = mkOption {
|
||||||
type = types.enum ["nix" "string" "derivation" "gotmpl" "jinja" "template"];
|
type = types.enum ["nix" "string" "derivation" "gotmpl" "jinja" "mustache" "template"];
|
||||||
description = ''
|
description = ''
|
||||||
Which engine to use for content generation.
|
Which engine to use for content generation.
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
1
tests/fixtures/mustache_template
vendored
Normal file
1
tests/fixtures/mustache_template
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Hello {{hello}}
|
||||||
|
|
@ -30,6 +30,12 @@
|
||||||
data.hello = "world";
|
data.hello = "world";
|
||||||
opts.template = ./fixtures/jinja_template;
|
opts.template = ./fixtures/jinja_template;
|
||||||
};
|
};
|
||||||
|
mustache = {
|
||||||
|
output = "mustache";
|
||||||
|
generator = "mustache";
|
||||||
|
data.hello = "world";
|
||||||
|
opts.template = ./fixtures/mustache_template;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
suites."Soonix Tests" = {
|
suites."Soonix Tests" = {
|
||||||
|
|
@ -53,6 +59,9 @@ in {
|
||||||
|
|
||||||
assert "-f ${finalFiles}/jinja" "should exist"
|
assert "-f ${finalFiles}/jinja" "should exist"
|
||||||
assert_file_contains ${finalFiles}/jinja "Hello world"
|
assert_file_contains ${finalFiles}/jinja "Hello world"
|
||||||
|
|
||||||
|
assert "-f ${finalFiles}/mustache" "should exist"
|
||||||
|
assert_file_contains ${finalFiles}/mustache "Hello world"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue