Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sentriz/tmplc

dead simple command line tool for go's standard library text/template
https://github.com/sentriz/tmplc

Last synced: 3 days ago
JSON representation

dead simple command line tool for go's standard library text/template

Awesome Lists containing this project

README

        

dead simple command line tool for go's standard library text/template

install:

$ go install go.senan.xyz/tmplc@latest

usage:

$ tmplc [FILE]...

FILE can be any number of "partials" or "leaves". where leaves have a ".tmpl" suffix, and partials are everything else.

after parsing all partials and leaves, new files will be created for the leaves without the ".tmpl" suffix.

it's even possible to use it as a static site generator:

$ cat partials
{{ define "layout" }}

{{ template "title" }}
{{ template "content" }}

{{ end }}

$ cat page-1.html.tmpl
{{ define "title" }}page one{{ end }}
{{ define "content" }}hello from page 1{{ end }}
{{ template "layout" }}

$ cat page-2.html.tmpl
{{ define "title" }}page two{{ end }}
{{ define "content" }}hello from page 2{{ end }}
{{ template "layout" }}

$ tmplc partials *.tmpl

$ cat page-1.html

page one
hello from page 1

$ cat page-2.html

page two
hello from page 2