mktpl
mktpl は YAML データと text/template の記法に従ったテンプレートを使ってテキストを標準出力にレンダリングするコマンドラインツールです。
Description
Demonstration
Motivation
- ロジックレスでシンプルなテンプレートエンジンの、mustache というものがある。
- Bash で実装された CLI もあるが、データの受け渡しがシェル変数または環境変数としてしか渡せず、データが増えてくるとつらい。
- ロジックレスなテンプレートが売りだが、やっぱり多少はロジックを含めたい。
Installation
Releases ページからダウンロードしてください。
Usage
$ mktpl --help
mktpl is a tool to render Golang text/template with template and YAML data files.
Usage:
mktpl flags
Flags (* is mandatory):
-d, --data string path to the YAML data file (*)
-t, --template string path to the template file (*)
-h, --help help for mktpl
-v, --version show program's version information and exit
Template Functions
{{ implode list separator }}
Same as strings.Join function.
{{ exec command [flags] [args] }}
Execute single external command and return it's stdout output.
Single means that no pipe (|), no redirection (>), no command connection (&, &&, ;, ||).
Arbitrary commands can be executed. Be very careful when using it.
{{ exclude list string... }}
Return a new list which is excluded specified strings from the elements in specified list.
License
The MIT License (MIT)
Author
Yuta MASANO