jigplate template [template ...]
Jigplate takes data from stdin in the form of JSON values and template files as arguments.
Objects will match the first template that has slots for each of its keys.
{"name": "hi", "title": "Welcome"}
<li><a href="/article/{name}">{title}</a></li>
$ echo '{"name": "hi", "title": "Welcome"}' | jigplate template/article-item.html
<li><a href="/article/hi">Welcome</a></li>
Arrays will concatenate their contents.
[{"name": "hi", "title": "Welcome"},
{"name": "intro", "title": "Introduction"}]
<li><a href="/article/{name}">{title}</a></li>
$ echo '[{"name": "hi", "title": "Welcome"}, {"name": "intro", "title": "Introduction"}]' | jigplate template/article-item.html
<li><a href="/article/hi">Welcome</a></li>
<li><a href="/article/intro">Introduction</a></li>
Nesting is done in the data, not in the templates.
{"articles": [{"name": "hi", "title": "Welcome"},
{"name": "intro", "title": "Introduction"}]}
<li><a href="/article/{name}">{title}</a></li>
<h2>Articles</h2>
<ul>
{articles}
</ul>
$ echo '{"articles": [{"name": "hi", "title": "Welcome"}, {"name": "intro", "title": "Introduction"}]}' | jigplate template/article-item.html template/page.html
<h2>Articles</h2>
<ul>
<li><a href="/article/hi">Welcome</a></li>
<li><a href="/article/intro">Introduction</a></li>
</ul>
I build jigplate with Nix to try to ensure reproducible builds:
nix build