chore: update code to latest dependencies and Nushell
This commit is contained in:
parent
da1ee63a25
commit
c0fbb0ff25
252
Cargo.lock
generated
252
Cargo.lock
generated
@ -144,6 +144,15 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "buf-trait"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21eaafc770e8c073d6c3facafe7617e774305d4954aa6351b9c452eb37ee17b4"
|
||||
dependencies = [
|
||||
"zerocopy 0.7.35",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.19.0"
|
||||
@ -164,9 +173,27 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
|
||||
[[package]]
|
||||
name = "bytesize"
|
||||
version = "1.3.3"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e93abca9e28e0a1b9877922aacb20576e05d4679ffa78c3d6dc22a26a216659"
|
||||
checksum = "f5c434ae3cf0089ca203e9019ebe529c47ff45cefe8af7c85ecb734ef541822f"
|
||||
|
||||
[[package]]
|
||||
name = "byteyarn"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b93e51d26468a15ea59f8525e0c13dc405db43e644a0b1e6d44346c72cf4cf7b"
|
||||
dependencies = [
|
||||
"buf-trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "castaway"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"
|
||||
dependencies = [
|
||||
"rustversion",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
@ -444,9 +471,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fancy-regex"
|
||||
version = "0.14.0"
|
||||
version = "0.16.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e24cb5a94bcae1e5408b0effca5cd7172ea3c5755049c5f3af4cd283a165298"
|
||||
checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"regex-automata",
|
||||
@ -594,9 +621,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.9.0"
|
||||
version = "2.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
|
||||
checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
@ -676,6 +703,18 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "lean_string"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "962df00ba70ac8d5ca5c064e17e5c3d090c087fd8d21aa45096c716b169da514"
|
||||
dependencies = [
|
||||
"castaway",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.174"
|
||||
@ -878,7 +917,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-cmd-base"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"miette",
|
||||
@ -890,11 +929,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-cmd-lang"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"itertools 0.14.0",
|
||||
"nu-cmd-base",
|
||||
"nu-engine",
|
||||
"nu-experimental",
|
||||
"nu-parser",
|
||||
"nu-protocol",
|
||||
"nu-utils",
|
||||
@ -903,7 +943,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-derive-value"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error2",
|
||||
@ -914,22 +954,32 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-engine"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"fancy-regex",
|
||||
"log",
|
||||
"nu-experimental",
|
||||
"nu-glob",
|
||||
"nu-path",
|
||||
"nu-protocol",
|
||||
"nu-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-experimental"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"itertools 0.14.0",
|
||||
"thiserror 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-glob"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
|
||||
[[package]]
|
||||
name = "nu-parser"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"bytesize",
|
||||
"chrono",
|
||||
@ -945,7 +995,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-path"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"omnipath",
|
||||
@ -955,7 +1005,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-plugin"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"log",
|
||||
"nix",
|
||||
@ -969,7 +1019,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-plugin-core"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"interprocess",
|
||||
"log",
|
||||
@ -983,7 +1033,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-plugin-engine"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"log",
|
||||
"nu-engine",
|
||||
@ -998,7 +1048,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-plugin-protocol"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"nu-protocol",
|
||||
"nu-utils",
|
||||
@ -1010,7 +1060,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-plugin-test-support"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"nu-ansi-term",
|
||||
"nu-cmd-lang",
|
||||
@ -1026,7 +1076,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-protocol"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"brotli",
|
||||
"bytes",
|
||||
@ -1043,6 +1093,7 @@ dependencies = [
|
||||
"miette",
|
||||
"nix",
|
||||
"nu-derive-value",
|
||||
"nu-experimental",
|
||||
"nu-glob",
|
||||
"nu-path",
|
||||
"nu-system",
|
||||
@ -1063,7 +1114,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-system"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"itertools 0.14.0",
|
||||
@ -1081,13 +1132,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nu-utils"
|
||||
version = "0.105.2"
|
||||
version = "0.107.1"
|
||||
dependencies = [
|
||||
"byteyarn",
|
||||
"crossterm",
|
||||
"crossterm_winapi",
|
||||
"fancy-regex",
|
||||
"lean_string",
|
||||
"log",
|
||||
"lscolors",
|
||||
"memchr",
|
||||
"nix",
|
||||
"num-format",
|
||||
"serde",
|
||||
@ -1142,6 +1196,25 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-core-foundation"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-io-kit"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71c1c64d6120e51cd86033f67176b1cb66780c2efe34dec55176f77befd93c0a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"objc2-core-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "omnipath"
|
||||
version = "0.1.6"
|
||||
@ -1314,7 +1387,7 @@ version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||
dependencies = [
|
||||
"zerocopy",
|
||||
"zerocopy 0.8.26",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1428,26 +1501,6 @@ dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "recvmsg"
|
||||
version = "1.0.0"
|
||||
@ -1655,9 +1708,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "shadow-rs"
|
||||
version = "1.2.0"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f6fd27df794ced2ef39872879c93a9f87c012607318af8621cd56d2c3a8b3a2"
|
||||
checksum = "b8aa5c0570cd9654158bd39f0f8caba24edbc058313946e89f4648b1de1ecf49"
|
||||
dependencies = [
|
||||
"const_format",
|
||||
"is_debug",
|
||||
@ -1800,16 +1853,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sysinfo"
|
||||
version = "0.33.1"
|
||||
version = "0.36.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01"
|
||||
checksum = "252800745060e7b9ffb7b2badbd8b31cfa4aa2e61af879d0a3bf2a317c20217d"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"memchr",
|
||||
"ntapi",
|
||||
"rayon",
|
||||
"windows 0.57.0",
|
||||
"objc2-core-foundation",
|
||||
"objc2-io-kit",
|
||||
"windows 0.61.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2229,12 +2282,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.57.0"
|
||||
version = "0.61.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
|
||||
checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"
|
||||
dependencies = [
|
||||
"windows-core 0.57.0",
|
||||
"windows-targets 0.52.6",
|
||||
"windows-collections",
|
||||
"windows-core 0.61.2",
|
||||
"windows-future",
|
||||
"windows-link",
|
||||
"windows-numerics",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-collections"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"
|
||||
dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2249,18 +2314,6 @@ dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.57.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
|
||||
dependencies = [
|
||||
"windows-implement 0.57.0",
|
||||
"windows-interface 0.57.0",
|
||||
"windows-result 0.1.2",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.61.2"
|
||||
@ -2275,21 +2328,21 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.56.0"
|
||||
name = "windows-future"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b"
|
||||
checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"windows-core 0.61.2",
|
||||
"windows-link",
|
||||
"windows-threading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.57.0"
|
||||
version = "0.56.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
|
||||
checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -2318,17 +2371,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.57.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.59.1"
|
||||
@ -2346,6 +2388,16 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
||||
|
||||
[[package]]
|
||||
name = "windows-numerics"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"
|
||||
dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.1.2"
|
||||
@ -2456,6 +2508,15 @@ dependencies = [
|
||||
"windows_x86_64_msvc 0.53.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-threading"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
@ -2594,13 +2655,34 @@ version = "0.53.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"zerocopy-derive 0.7.35",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
"zerocopy-derive 0.8.26",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
12
Cargo.toml
12
Cargo.toml
@ -12,13 +12,13 @@ license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
# for local development, you can use a path dependency
|
||||
nu-plugin = { path = "../nushell/crates/nu-plugin" }
|
||||
nu-protocol = { path = "../nushell/crates/nu-protocol", features = ["plugin"] }
|
||||
nu-plugin = { version = "0.107.1", path = "../nushell/crates/nu-plugin" }
|
||||
nu-protocol = { version = "0.107.1", path = "../nushell/crates/nu-protocol", features = ["plugin"] }
|
||||
#nu-plugin = "0.104.0"
|
||||
#nu-protocol = { version = "0.104.0", features = ["plugin"] }
|
||||
tera = "1.3"
|
||||
#nu-protocol = { version = "0.107.1", version = "0.107.1", features = ["plugin"] }
|
||||
tera = "1.20"
|
||||
serde_json = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
nu-plugin-test-support = { path = "../nushell/crates/nu-plugin-test-support" }
|
||||
#nu-plugin-test-support = { version = "0.104.0" }
|
||||
nu-plugin-test-support = { version = "0.107.1", path = "../nushell/crates/nu-plugin-test-support" }
|
||||
#nu-plugin-test-support = { version = "0.107.1", version = "0.107.1" }
|
473
README.md
473
README.md
@ -1,6 +1,10 @@
|
||||
# nu_plugin_tera
|
||||
|
||||
A [Nushell](https://nushell.sh/) plugin to use [Tera templates](https://keats.github.io/tera/docs/).
|
||||
A powerful [Nushell](https://nushell.sh/) plugin for rendering [Tera templates](https://keats.github.io/tera/docs/) with structured data from Nushell pipelines.
|
||||
|
||||
## Overview
|
||||
|
||||
This plugin integrates Mozilla's Tera templating engine with Nushell, enabling you to generate dynamic content from structured data. Perfect for configuration files, documentation generation, reports, and any scenario where you need to combine templates with data.
|
||||
|
||||
## Installing
|
||||
|
||||
@ -10,7 +14,7 @@ Clone this repository
|
||||
> **nu_plugin_tera** has dependencies to nushell source via local path in Cargo.toml
|
||||
> Nushell and plugins require to be **sync** with same **version**
|
||||
|
||||
Clone [Nushell](https://nushell.sh/) to plugin to use [Tera templates](https://keats.github.io/tera/docs/) or change dependecies in [Cargo.toml](Cargo.toml)
|
||||
Clone [Nushell](https://nushell.sh/) alongside this plugin or change dependencies in [Cargo.toml](Cargo.toml)
|
||||
|
||||
This plugin is also included as submodule in [nushell-plugins](https://repo.jesusperez.pro/jesus/nushell-plugins)
|
||||
as part of plugins collection for [Provisioning project](https://rlung.librecloud.online/jesus/provisioning)
|
||||
@ -30,24 +34,68 @@ In a [Nushell](https://nushell.sh/)
|
||||
> plugin add ~/.cargo/bin/nu_plugin_tera
|
||||
```
|
||||
|
||||
## Usage
|
||||
## Commands
|
||||
|
||||
### `tera-render`
|
||||
|
||||
Render Tera templates with structured data from Nushell pipelines or arguments.
|
||||
|
||||
```nushell
|
||||
> tera-render <template> (context)
|
||||
> tera-render <template> [context]
|
||||
```
|
||||
|
||||
Flags:
|
||||
**Parameters:**
|
||||
- **template** `<path>`: Path to the `.tera` template file
|
||||
- **context** `<any>`: Context data (record or JSON file path) (optional)
|
||||
|
||||
**Flags:**
|
||||
- **-h**, **--help**: Display the help message for this command
|
||||
|
||||
Parameters:
|
||||
- **template** <path>: Ruta al archivo .tera
|
||||
- **context** <any>: Datos de contexto (record o JSON path) (optional)
|
||||
## Template Syntax
|
||||
|
||||
Tera uses a Jinja2-inspired syntax with powerful features:
|
||||
|
||||
### Examples
|
||||
### Basic Variables
|
||||
```jinja2
|
||||
Hello, {{ name }}!
|
||||
Your age is {{ age }}.
|
||||
```
|
||||
|
||||
Render **template.tera** with a record as context from the pipeline.
|
||||
### Control Structures
|
||||
```jinja2
|
||||
{% if user.is_admin %}
|
||||
<p>Welcome, admin!</p>
|
||||
{% else %}
|
||||
<p>Welcome, user!</p>
|
||||
{% endif %}
|
||||
|
||||
{% for item in items %}
|
||||
- {{ item.name }}: {{ item.value }}
|
||||
{% endfor %}
|
||||
```
|
||||
|
||||
### Filters
|
||||
```jinja2
|
||||
{{ name | upper }}
|
||||
{{ price | round(precision=2) }}
|
||||
{{ date | date(format="%Y-%m-%d") }}
|
||||
```
|
||||
|
||||
### Macros
|
||||
```jinja2
|
||||
{% macro render_field(name, value) %}
|
||||
<div class="field">
|
||||
<label>{{ name }}</label>
|
||||
<span>{{ value }}</span>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{{ render_field(name="Username", value=user.name) }}
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
**data.json**
|
||||
```json
|
||||
@ -57,31 +105,412 @@ Render **template.tera** with a record as context from the pipeline.
|
||||
{
|
||||
"name": "TheProject",
|
||||
"status": "active"
|
||||
},
|
||||
{
|
||||
"name": "AnotherProject",
|
||||
"status": "completed"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**template.tera**
|
||||
```jinja
|
||||
Hello, {{ name }}!Projects:
|
||||
```jinja2
|
||||
Hello, {{ name }}!
|
||||
|
||||
Projects:
|
||||
{% for project in projects -%}
|
||||
- {{ project.name }} ({{ project.status }})
|
||||
{% endfor %}
|
||||
```
|
||||
|
||||
### Other options
|
||||
|
||||
**Rendering:**
|
||||
```nushell
|
||||
> open data.json | wrap value | tera-render template.tera
|
||||
> open data.json | tera-render template.tera
|
||||
> { name: 'Akasha', projects: [ {'name': 'TheProject' , 'status': 'active' }] } | tera-render template.tera
|
||||
Hello, Akasha!
|
||||
|
||||
Projects:
|
||||
- TheProject (active)
|
||||
- AnotherProject (completed)
|
||||
```
|
||||
|
||||
Result:
|
||||
<pre>
|
||||
Hello, Akasha!
|
||||
Projects:
|
||||
- TheProject (active)
|
||||
</pre>
|
||||
### Pipeline Data Processing
|
||||
|
||||
```nushell
|
||||
# Process system information
|
||||
> sys | tera-render system-report.tera
|
||||
|
||||
# Generate configuration files from structured data
|
||||
> {
|
||||
server: {
|
||||
host: "localhost",
|
||||
port: 8080,
|
||||
ssl: true
|
||||
},
|
||||
database: {
|
||||
host: "db.example.com",
|
||||
name: "myapp"
|
||||
}
|
||||
} | tera-render config.tera
|
||||
|
||||
# Process CSV data
|
||||
> open employees.csv
|
||||
| tera-render employee-report.tera
|
||||
```
|
||||
|
||||
### Multiple Data Sources
|
||||
|
||||
```nushell
|
||||
# Using JSON file as context
|
||||
> tera-render template.tera data.json
|
||||
|
||||
# Using record from pipeline
|
||||
> { name: 'Akasha', projects: [ {'name': 'TheProject', 'status': 'active'} ] }
|
||||
| tera-render template.tera
|
||||
|
||||
# Wrapping data for template access
|
||||
> open data.json | wrap value | tera-render template.tera
|
||||
```
|
||||
|
||||
## Advanced Templates
|
||||
|
||||
### Configuration File Generation
|
||||
|
||||
**nginx.conf.tera**
|
||||
```jinja2
|
||||
server {
|
||||
listen {{ server.port }}{% if server.ssl %} ssl{% endif %};
|
||||
server_name {{ server.host }};
|
||||
|
||||
{% if server.ssl %}
|
||||
ssl_certificate {{ ssl.cert_path }};
|
||||
ssl_certificate_key {{ ssl.key_path }};
|
||||
{% endif %}
|
||||
|
||||
{% for location in locations %}
|
||||
location {{ location.path }} {
|
||||
proxy_pass {{ location.upstream }};
|
||||
{% for header in location.headers | default(value=[]) %}
|
||||
proxy_set_header {{ header.name }} {{ header.value }};
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
}
|
||||
```
|
||||
|
||||
**Usage:**
|
||||
```nushell
|
||||
> {
|
||||
server: {
|
||||
host: "example.com",
|
||||
port: 443,
|
||||
ssl: true
|
||||
},
|
||||
ssl: {
|
||||
cert_path: "/etc/ssl/cert.pem",
|
||||
key_path: "/etc/ssl/key.pem"
|
||||
},
|
||||
locations: [
|
||||
{
|
||||
path: "/api/",
|
||||
upstream: "http://backend:8080",
|
||||
headers: [
|
||||
{name: "Host", value: "$host"},
|
||||
{name: "X-Real-IP", value: "$remote_addr"}
|
||||
]
|
||||
}
|
||||
]
|
||||
} | tera-render nginx.conf.tera | save nginx.conf
|
||||
```
|
||||
|
||||
### Documentation Generation
|
||||
|
||||
**api-docs.md.tera**
|
||||
```jinja2
|
||||
# {{ api.title }} API Documentation
|
||||
|
||||
Version: {{ api.version }}
|
||||
Last updated: {{ "now" | date(format="%Y-%m-%d") }}
|
||||
|
||||
## Endpoints
|
||||
|
||||
{% for endpoint in api.endpoints %}
|
||||
### {{ endpoint.method | upper }} {{ endpoint.path }}
|
||||
|
||||
{{ endpoint.description }}
|
||||
|
||||
{% if endpoint.parameters %}
|
||||
**Parameters:**
|
||||
{% for param in endpoint.parameters %}
|
||||
- `{{ param.name }}` ({{ param.type }}){% if param.required %} *required*{% endif %}: {{ param.description }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
**Example Response:**
|
||||
```json
|
||||
{{ endpoint.example_response | tojson }}
|
||||
```
|
||||
|
||||
---
|
||||
{% endfor %}
|
||||
```
|
||||
|
||||
### Report Generation
|
||||
|
||||
```nushell
|
||||
# Generate system report
|
||||
def generate-system-report [] {
|
||||
let data = {
|
||||
timestamp: (date now | format date "%Y-%m-%d %H:%M:%S"),
|
||||
system: (sys),
|
||||
processes: (ps | first 10),
|
||||
disk_usage: (df)
|
||||
}
|
||||
|
||||
$data | tera-render system-report.html.tera | save $"reports/system-report-(date now | format date "%Y%m%d").html"
|
||||
}
|
||||
|
||||
# Generate project status report
|
||||
def generate-project-report [project_dir: string] {
|
||||
let data = {
|
||||
project: (open $"($project_dir)/package.json" | get name),
|
||||
files: (ls $project_dir | length),
|
||||
git_status: (git -C $project_dir status --porcelain | lines),
|
||||
last_commit: (git -C $project_dir log -1 --format="%h %s %an %ad" --date=short)
|
||||
}
|
||||
|
||||
$data | tera-render project-report.md.tera
|
||||
}
|
||||
```
|
||||
|
||||
## Workflow Examples
|
||||
|
||||
### CI/CD Pipeline Configuration
|
||||
|
||||
```nushell
|
||||
# Generate Kubernetes manifests
|
||||
def generate-k8s-manifests [env: string] {
|
||||
let config = (open $"configs/($env).json")
|
||||
|
||||
[
|
||||
"deployment.yaml.tera",
|
||||
"service.yaml.tera",
|
||||
"ingress.yaml.tera"
|
||||
] | each { |template|
|
||||
let output = ($config | tera-render $"templates/($template)")
|
||||
$output | save $"manifests/($env)/(($template | str replace '.tera' ''))"
|
||||
}
|
||||
}
|
||||
|
||||
# Generate environment-specific configs
|
||||
def generate-env-configs [] {
|
||||
["dev", "staging", "prod"] | each { |env|
|
||||
let base_config = (open base-config.json)
|
||||
let env_config = (open $"($env)-config.json")
|
||||
let merged = ($base_config | merge $env_config)
|
||||
|
||||
$merged | tera-render app-config.yaml.tera | save $"configs/($env).yaml"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Content Management
|
||||
|
||||
```nushell
|
||||
# Generate blog posts from structured data
|
||||
def generate-blog-posts [] {
|
||||
ls content/*.json
|
||||
| each { |post_file|
|
||||
let post_data = (open $post_file.name)
|
||||
let filename = ($post_file.name | path basename | str replace '.json' '.html')
|
||||
|
||||
$post_data | tera-render blog-post.html.tera | save $"output/($filename)"
|
||||
}
|
||||
}
|
||||
|
||||
# Generate navigation menus
|
||||
def generate-navigation [site_config: string] {
|
||||
open $site_config
|
||||
| get pages
|
||||
| tera-render navigation.html.tera
|
||||
| save includes/navigation.html
|
||||
}
|
||||
```
|
||||
|
||||
### Infrastructure as Code
|
||||
|
||||
```nushell
|
||||
# Generate Terraform configurations
|
||||
def generate-terraform [environment: string] {
|
||||
let vars = (open $"terraform/($environment).tfvars.json")
|
||||
|
||||
ls terraform/templates/*.tf.tera
|
||||
| each { |template|
|
||||
let output_name = ($template.name | path basename | str replace '.tera' '')
|
||||
$vars | tera-render $template.name | save $"terraform/($environment)/($output_name)"
|
||||
}
|
||||
}
|
||||
|
||||
# Generate Docker Compose files
|
||||
def generate-docker-compose [services: list] {
|
||||
let compose_data = {
|
||||
services: $services,
|
||||
networks: ["app-network"],
|
||||
volumes: ["db-data", "app-logs"]
|
||||
}
|
||||
|
||||
$compose_data | tera-render docker-compose.yml.tera | save docker-compose.yml
|
||||
}
|
||||
```
|
||||
|
||||
## Integration with Nushell Data Processing
|
||||
|
||||
Leverage Nushell's powerful data manipulation with Tera templating:
|
||||
|
||||
```nushell
|
||||
# Process and template CSV data
|
||||
> open sales.csv
|
||||
| group-by region
|
||||
| transpose region sales
|
||||
| insert total { |row| $row.sales | math sum }
|
||||
| tera-render sales-report.html.tera
|
||||
| save reports/sales-summary.html
|
||||
|
||||
# Combine multiple data sources
|
||||
> let weather = (http get "https://api.weather.com/current")
|
||||
> let system = (sys)
|
||||
> {weather: $weather, system: $system}
|
||||
| tera-render dashboard.html.tera
|
||||
|
||||
# Batch process templates
|
||||
> ls templates/*.tera
|
||||
| each { |template|
|
||||
let data = (open $"data/(($template.name | path basename | str replace '.tera' '.json'))")
|
||||
$data | tera-render $template.name
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
The plugin provides detailed error messages for common issues:
|
||||
|
||||
```nushell
|
||||
# Template syntax errors
|
||||
> {} | tera-render broken-template.tera
|
||||
Error: Template error
|
||||
╭─[calling tera-render]
|
||||
│ Template parse error: Unexpected token...
|
||||
|
||||
# Missing variables
|
||||
> {} | tera-render template-with-vars.tera
|
||||
Error: Render error
|
||||
╭─[calling tera-render]
|
||||
│ Variable 'name' not found in context
|
||||
|
||||
# File not found
|
||||
> {} | tera-render nonexistent.tera
|
||||
Error: Read error
|
||||
╭─[calling tera-render]
|
||||
│ Failed to read file 'nonexistent.tera': No such file...
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- ✅ **Pipeline Integration** - Seamlessly process Nushell data structures
|
||||
- ✅ **Multiple Data Sources** - Support for JSON files, records, and pipeline data
|
||||
- ✅ **Rich Template Syntax** - Full Tera templating features (filters, macros, inheritance)
|
||||
- ✅ **Error Handling** - Detailed error messages with context
|
||||
- ✅ **File I/O** - Read templates from files, save rendered output
|
||||
- ✅ **Data Wrapping** - Automatic handling of different data structures
|
||||
- ✅ **Performance** - Efficient template compilation and rendering
|
||||
|
||||
## Use Cases
|
||||
|
||||
- **Configuration Management**: Generate environment-specific config files
|
||||
- **Documentation**: Create dynamic documentation from structured data
|
||||
- **Infrastructure as Code**: Template Terraform, Kubernetes, Docker configurations
|
||||
- **Reports**: Generate HTML/Markdown reports from system data
|
||||
- **Web Development**: Template generation for static sites
|
||||
- **CI/CD**: Dynamic pipeline configurations
|
||||
- **Content Management**: Blog posts, newsletters, and content generation
|
||||
- **Monitoring**: Dashboard and alert template generation
|
||||
|
||||
## Template Best Practices
|
||||
|
||||
### 1. Organize Templates
|
||||
```
|
||||
templates/
|
||||
├── base.html.tera # Base layouts
|
||||
├── components/
|
||||
│ ├── header.html.tera # Reusable components
|
||||
│ └── footer.html.tera
|
||||
├── pages/
|
||||
│ ├── home.html.tera # Page templates
|
||||
│ └── about.html.tera
|
||||
└── configs/
|
||||
├── nginx.conf.tera # Configuration templates
|
||||
└── docker.yml.tera
|
||||
```
|
||||
|
||||
### 2. Use Template Inheritance
|
||||
**base.html.tera**
|
||||
```jinja2
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% block title %}{{ site.title }}{% endblock %}</title>
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
**page.html.tera**
|
||||
```jinja2
|
||||
{% extends "base.html.tera" %}
|
||||
|
||||
{% block title %}{{ page.title }} - {{ site.title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ page.title }}</h1>
|
||||
{{ page.content }}
|
||||
{% endblock %}
|
||||
```
|
||||
|
||||
### 3. Create Reusable Functions
|
||||
```nushell
|
||||
# Template rendering helper
|
||||
def render-template [template: string, data: any] {
|
||||
$data | tera-render $template
|
||||
}
|
||||
|
||||
# Batch template processing
|
||||
def render-all-templates [data_dir: string, template_dir: string, output_dir: string] {
|
||||
ls $"($data_dir)/*.json"
|
||||
| each { |data_file|
|
||||
let basename = ($data_file.name | path basename | str replace '.json' '')
|
||||
let template = $"($template_dir)/($basename).tera"
|
||||
let output = $"($output_dir)/($basename).html"
|
||||
|
||||
if ($template | path exists) {
|
||||
open $data_file.name | tera-render $template | save $output
|
||||
print $"Generated: ($output)"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
|
||||
## Related Projects
|
||||
|
||||
- [Tera](https://keats.github.io/tera/) - Template engine for Rust
|
||||
- [Nushell](https://nushell.sh/) - A new type of shell
|
||||
- [nu_plugin_fluent](../nu_plugin_fluent/) - Fluent localization plugin for Nushell
|
1
nu_plugin_fluent
Submodule
1
nu_plugin_fluent
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 7f11208aef1ad6db0530ce5e15402d52e326daea
|
@ -63,7 +63,7 @@ impl SimplePluginCommand for Render {
|
||||
}
|
||||
|
||||
/// Example usages of the command for Nushell help and testing.
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
fn examples(&self) -> Vec<Example<'_>> {
|
||||
vec![Example {
|
||||
example: "{ name: 'Akasha', projects: [ {'name': 'TheProject' , 'status': 'active' }] } | tera-render example/template.tera",
|
||||
description: "Render template.tera with a record as context from the pipeline.\n\n\
|
||||
|
Loading…
x
Reference in New Issue
Block a user