genfront

command module
v0.1.2-0...-b48ce14 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: EPL-1.0 Imports: 6 Imported by: 0

README

Build Status

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

---
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, 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.

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