tmplscript

command module
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

tmplscript

GoTest MIT License

executable go-template command (like awk and jq!)

install

Get binary here.

You can also install from go install.

$ go install github.com/syuparn/tmplscript@latest

usage

$ go install github.com/syuparn/tmplscript@latest
$ echo "hello" | tmplscript '{{print . ", " "world!"}}'
hello, world!
# read from file instead
$ seq 15 | tmplscript -f example/fizzbuzz.tmpl
1
2
fizz
...

REPL mode

$ tmplscript -i
tmpl:1> {{add 2 3}}
5
tmpl:2> {{$i := "Hello"}}

tmpl:3> {{print $i ", world!"}}
Hello, world!
tmpl:4> ^C

In REPL mode, you can use histories and function autocompletes. See peterh/liner for details.

functions

Functions in Sprig are available.

(Of course template standard functions too!)

Also, you can use searchFunc to search defined functions and docFunc to check function's arguments.

$ tmplscript -i
tmpl:1> {{searchFunc "a"}}
[abbrev adler32sum atoi ago add1 add append abbrevboth]
tmpl:2> {{docFunc "atoi"}}
atoi string -> (int)

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
⌂ 换网址