rgen

package
v0.0.0-...-eeb478c Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultIncludeFunc

func DefaultIncludeFunc(path, fileName string) bool

DefaultIncludeFunc will return true for any file which ends with .vugu.

func DefaultPathFunc

func DefaultPathFunc(fileName string) string

DefaultPathFunc will return the fileName with any suffix removed and a slash prepended. E.g. file name "example.vugu" will return "/example". The special case of index.vugu will return "/".

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator performs route generation on a given directory (and optionally sub-directories)

func New

func New() *Generator

New returns a new Generator instance.

func (*Generator) Generate

func (g *Generator) Generate() error

Generate does the route generation.

func (*Generator) SetDir

func (g *Generator) SetDir(dir string) *Generator

SetDir assigns the directory to start generating in.

func (*Generator) SetIncludeFunc

func (g *Generator) SetIncludeFunc(f func(path, fileName string) bool) *Generator

SetIncludeFunc sets the function which determines which files are included in the route map. The include function will be passed the path relative to the dir set by SetDir (and will be empty for files in that directory) and fileName will contain the base file name. E.g. given SetDir("/a") "/a/b.vugu" will result in a call with ("", "b.vugu"), and "/a/b/c.vugu" will result in a call with ("b", "c.vugu"), "/a/b/c/d.vugu" with ("b/c", "d.vugu") and so on.

func (*Generator) SetPackageName

func (g *Generator) SetPackageName(packageName string) *Generator

SetPackageName sets the fully qualified package name that corresponds with the directory set with SetDir.

func (*Generator) SetPathFunc

func (g *Generator) SetPathFunc(f func(fileName string) string) *Generator

SetPathFunc sets a function which transforms. If not set, DefaultPathFunc will be used.

func (*Generator) SetRecursive

func (g *Generator) SetRecursive(recursive bool) *Generator

SetRecursive if passed true will enable the generator recursing into sub-directories.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL