Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lcaballero/genfront
A tool for use with go generate. Take front-matter file (yaml + go html templating) and process them for code generation.
https://github.com/lcaballero/genfront
Last synced: 23 days ago
JSON representation
A tool for use with go generate. Take front-matter file (yaml + go html templating) and process them for code generation.
- Host: GitHub
- URL: https://github.com/lcaballero/genfront
- Owner: lcaballero
- License: epl-1.0
- Created: 2015-09-22T20:30:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T20:11:57.000Z (almost 7 years ago)
- Last Synced: 2024-06-20T06:26:37.331Z (7 months ago)
- Language: Go
- Homepage:
- Size: 414 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/lcaballero/genfront.svg?branch=master)](https://travis-ci.org/lcaballero/genfront)
# Overview
`genfront` is a code generating tool. `genfront` provides several
subcommands for different generating patterns. See the usage below.## Subcommands
#### front
Parses a front-matter file and renders the template therein providing
the static embedded yaml data.#### fields
Placed above a struct, it provides struct fields as data to the
template for rendering.## Example Usage
### With Front Matter
```
//go:generate genfront front --input req_methods.fm --output req_methods.go
```*req_methods.fm*
```go
---
methods:
- OPTIONS
- GET
- HEAD
- POST
- PUT
- DELETE
- TRACE
- CONNECT
---
package {{ .ENV.GOPACKAGE }}
{{ .ENV.GEN_TAGLINE }}
// {{ getenv "GOLINE" }}const (
{{ range .methods }} {{ . }} = "{{ . }}"
{{ end }})// Methods for the Rest state{{ range .methods }}
func (r *Rest) {{ . | title }}() *Rest {
return r.Method({{ . }})
}{{ end }}// Methods for Req state{{ range .methods }}
func (r *Req) {{ . | title }}() *Req {
return r.Method({{ . }})
}{{ end }}
```## Template Helpers
#### title
#### lower
#### toSymbol
#### getenv
#### split
#### camelCase
#### hasPrefix## License
See license file.
The use and distribution terms for this software are covered by the
[Eclipse Public License 1.0][EPL-1], which can be found in the file 'license' at the
root of this distribution. By using this software in any fashion, you are
agreeing to be bound by the terms of this license. You must not remove this
notice, or any other, from this software.[EPL-1]: http://opensource.org/licenses/eclipse-1.0.txt
[Front Matter]: https://jekyllrb.com/docs/frontmatter/
[Yaml]: http://yaml.org/
[Handlebars]: http://handlebarsjs.com/