mktpl

command module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 13 Imported by: 0

README

mktpl

mktpl は YAML データと text/template の記法に従ったテンプレートを使ってテキストを標準出力にレンダリングするコマンドラインツールです。

Description

  • コマンドオプションで YAML 形式のデータファイルと text/template スタイルのテンプレートファイルのパスを指定すると、テキストが標準出力にレンダリングされる。
  • YAML データファイルではハッシュの値にキーを指定することができる。
  • 独自のテンプレート関数を実装している。
  • Masterminds/sprig: Useful template functions for Go templates. も使える。

Demonstration

demo

Motivation

VS mustache
  • ロジックレスでシンプルなテンプレートエンジンの、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

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