init repo
This commit is contained in:
commit
f5bdbe9b79
63
README.md
Normal file
63
README.md
Normal file
@ -0,0 +1,63 @@
|
||||
# nu_plugin_tera
|
||||
|
||||
A [Nushell](https://nushell.sh/) plugin to use [Tera templates](https://keats.github.io/tera/docs/).
|
||||
|
||||
## Installing
|
||||
|
||||
Clone this repository
|
||||
|
||||
Build from source
|
||||
|
||||
```nushell
|
||||
> cargo install --path .
|
||||
```
|
||||
|
||||
### Nushell
|
||||
|
||||
In a [Nushell](https://nushell.sh/)
|
||||
|
||||
```nushell
|
||||
> plugin add ~/.cargo/bin/nu_plugin_tera
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```nushell
|
||||
> tera-render <template> (context)
|
||||
```
|
||||
|
||||
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)
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
Render **template.tera** with a record as context from the pipeline.
|
||||
|
||||
template.tera:
|
||||
```jinja
|
||||
Hello, {{ name }}!Projects:
|
||||
{% for project in projects -%}
|
||||
- {{ project.name }} ({{ project.status }})
|
||||
{% endfor %}
|
||||
```
|
||||
|
||||
### Other options
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
Result:
|
||||
<pre>
|
||||
Hello, Akasha!
|
||||
Projects:
|
||||
- TheProject (active)
|
||||
</pre>
|
||||
|
Loading…
x
Reference in New Issue
Block a user