makeshift/pkg/plugins/jinja2/README.md

34 lines
1.4 KiB
Markdown

# Makeshift Jinja 2 Plugin
This is a `makeshift` plugin that allows rendering files with Jinja 2 grammar. The plugin reads from a `storage.KVStore` passed to the `Run()` function and substitute the values in files provided with key `file`. Profiles can also be used to inject data into the store as well.
Compile the plugin if not done already.
```bash
makeshift compile pkg/plugins/jinja2/jinja2.go -o $MAKESHIFT_ROOT/plugins/jinja.so
```
Then, try download a file that contains Jinja2 variables. The `makeshift` server includes a `help.txt` and `default.json` profile to show how rendering can be done with downloads, profiles, and plugins.
First, try downloading the `help.txt` file *without* rendering.
```bash
makeshift download -p help.txt
```
Notice that there are Jinja2 variables with no substitutions done here. Now, try it again with the `jinja2` plugin and the `default` profile.
```bash
makeshift download -p help.txt --plugins jinja2 --profile default
```
You should see the same file, but now the values are populated with the content stored in the profile. Remember...the data can also be populated using other plugins as well (see the [`smd`](../smd/README.md) plugin regarding this).
Also, keep in mind that rendering happens across directories as well.
```bash
makeshift download -p templates --plugins jinja2 --profile
default
```
This will render all Jinja 2 templates before archiving and downloading the files with the client.