Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

flowonyx/runtemplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

runtemplate

This application provides a way of doing template execution from standard Go templates from the command line.

You can install it with:

go get github.com/flowonyx/runtemplate

It is intended primarily to be used with go generate. Simply put the go generate comment in your code like this:

//go:generate runtemplate filename.tpl outfile.go Option1=Value1 Option2=Value2

Then run go generate and it will run this against the specified template, passing in whatever options have have been specified on the command line as a map.

In the template file, you can then access them simply by their keys. For instance:

{{ .Option1 }}

.OutFile and .TemplateFile are always available to the templates.

Also included are some filters that may be helpful.

  • title - Converts the input to Title Case.
  • upper - Converts the input to UPPER CASE.
  • lower - Converts the input to lower case.
  • splitDotFirst - Given an input that has a '.' separator, returns the part before the first '.'.
  • splitDotLast - Given an input that has a '.' separator, returns the part after the last '.'.

The last two are useful for getting only the package name or only the type name if passed an input of package.Type.

About

Provides a way of doing template execution from standard Go templates from the command line.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages