A Nushell plugin to use Tera templates.
Clone this repository
Warning
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 to plugin to use Tera templates or change dependecies in Cargo.toml
This plugin is also included as submodule in nushell-plugins as part of plugins collection for Provisioning project
Build from source
> cd nu_plugin_tera
> cargo install --path .In a Nushell
> plugin add ~/.cargo/bin/nu_plugin_tera> tera-render <template> (context)Flags:
- -h, --help: Display the help message for this command
Parameters:
- template : Ruta al archivo .tera
- context : Datos de contexto (record o JSON path) (optional)
Render template.tera with a record as context from the pipeline.
data.json
{
"name": "Akasha",
"projects": [
{
"name": "TheProject",
"status": "active"
}
]
}template.tera
Hello, {{ name }}!Projects:
{% for project in projects -%}
- {{ project.name }} ({{ project.status }})
{% endfor %}> 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.teraResult:
Hello, Akasha! Projects: - TheProject (active)