https://github.com/bouk/statictemplate
Statictemplate is a code generator for Go's text/template and html/template.
https://github.com/bouk/statictemplate
Last synced: about 1 year ago
JSON representation
Statictemplate is a code generator for Go's text/template and html/template.
- Host: GitHub
- URL: https://github.com/bouk/statictemplate
- Owner: bouk
- License: mit
- Created: 2016-09-02T17:16:37.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-08-21T12:20:56.000Z (almost 8 years ago)
- Last Synced: 2025-03-18T06:11:42.360Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 72.3 KB
- Stars: 78
- Watchers: 1
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# statictemplate
Statictemplate is a code generator for Go's text/template and html/template packages. It works by reading in the template files, and generating the needed functions based on the combination of requested function names and type signatures.
Please read [my blogpost](http://bouk.co/blog/code-generating-code/) about this project for some background.
## Installation
To install the commandline tool, run `go get bou.ke/statictemplate`.
## Usage
These are the supported flags:
```
Usage of statictemplate:
-dev string
Name of the dev output file
-funcs string
A reference to a custom Funcs map to include
-html
Interpret templates as HTML, to enable Go's automatic HTML escaping
-o string
Name of the output file (default "template.go")
-package string
Name of the package of the result file. Defaults to name of the folder of the output file
-t value
Target to process, supports multiple. The format is ::
```
After the flags you pass in one or more globs to specify the templates.
The example in this project uses the following command
```
statictemplate -html -o example/template/template.go -t "Index:index.tmpl:[]bou.ke/statictemplate/example.Post" example/template/*.tmpl
```
## Docs
[Check out the docs](https://godoc.org/bou.ke/statictemplate/statictemplate).