Skip to content
techdecafPublic

About

golang text/template library with added functions and features

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Template Functions

Examples

Operating System Helpers

  • OS {{OS}} resolves to current running os runtime.GOOS
  • ARCH {{ARCH}} resolves to current processor architecture runtime.GOARCH

File and Path Functions

  • PWD {{PWD}} resolves to current working directory
  • FromSlash {{FromSlash}} uses go function filepath.FromSlash
  • ToSlash {{ToSlash}} uses go function filepath.ToSlash
  • ReadFile {{ReadFile}} read file contents, supports relative or absolute paths.
  • WriteFile {{WriteFile 'file/path' 'string data'}} write file contents, supports relative or absolute paths.
  • RemoveAll {{RemoveAll 'file/path'}} CAUTION removes file or folder and all children
  • MkdirAll {{MkdirAll}}
  • Touch {{Touch}}

String Functions

  • ToTitle {{ToTitle}} uses go function strings.Title
  • ToUpper {{ToUpper}} uses go function strings.ToUpper
  • ToLower {{ToLower}} uses go function strings.ToLower
  • Replace {{Replace}} uses go function strings.Replace

Execution Functions

EXEC

{{EXEC `echo "hello"`}}

TRY

{{TRY `fails` | default `default value`}}

Expand

{{Expand}}

ExpandFile

{{ReadFile `my-template-file.yaml` | ExpandFile | WriteFile}}

JQ

{{JQ 'key.value[0]', '{"key": {"value":[1]} }'}}
{{ReadFile `my-file.json` | JQ `key.value[0]`}}

YQ

{{ReadFile `my-file.yaml` | YQ `key.value[0]`}}

About

golang text/template library with added functions and features

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages

⌂ 换网址