simplej2

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 7 Imported by: 0

README

simplej2

Simplej2 is very simple tool to process existing jinja2 templates while using a JSON file for the necessary variables used in the template.

Usage

The main purpose of simplej2 is to process a folder containing Jinja2 templates and save the generated files in a target directory, where the same directory structure is generated as in the source folder. If the source is a directory, only files ending on .j2 are processed. For the resulting files, this suffix is stripped.

If the source is a single file, the file ending does not matter.

simplej2 <value.json> <src> <destDir>

The value.json file does have the following structure:

{
  "variable1": true,
  "variable2": "foobar"
}

Given the following template,

{% if variable1 %}
{{ variable2 }}
{% endif %}

a resulting file with the following content is produced.

foobar

The rendering is done with gonja, which is originally based on pongo2, but does support Jinja2 template syntax instead of Django template syntax (for differences see https://jinja.palletsprojects.com/en/2.10.x/switching/#django).

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL