templates

package
v0.0.0-...-a82cec0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package templates contains the various Go code templates used by xo.

Index

Constants

This section is empty.

Variables

View Source
var KnownTypeMap = map[string]bool{
	"bool":    true,
	"string":  true,
	"byte":    true,
	"rune":    true,
	"int":     true,
	"int16":   true,
	"int32":   true,
	"int64":   true,
	"uint":    true,
	"uint8":   true,
	"uint16":  true,
	"uint32":  true,
	"uint64":  true,
	"float32": true,
	"float64": true,
}

KnownTypeMap is the collection of known Go types.

View Source
var ShortNameTypeMap = map[string]string{
	"bool":    "b",
	"string":  "s",
	"byte":    "b",
	"rune":    "r",
	"int":     "i",
	"int16":   "i",
	"int32":   "i",
	"int64":   "i",
	"uint":    "u",
	"uint8":   "u",
	"uint16":  "u",
	"uint32":  "u",
	"uint64":  "u",
	"float32": "f",
	"float64": "f",
}

ShortNameTypeMap is the collection of Go style short names for types, mainly used for use with declaring a func receiver on a type.

View Source
var Tpls = map[string]*template.Template{}

Tpls is the collection of template assets.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type EnumTemplate

type EnumTemplate struct {
	Type     string
	EnumType string
	Comment  string
	Values   []*models.Enum
}

EnumTemplate is a template item for a enum.

type FkTemplate

type FkTemplate struct {
	Type       string
	ColumnName string
	Field      string
	RefType    string
	RefField   string
}

FkTemplate is a template item for a foreign relationship on a table.

type FuncTemplate

type FuncTemplate struct {
	Name          string
	Type          string
	Query         []string
	QueryComments []string
	Parameters    [][]string
	OnlyOne       bool
	Comment       string
	Table         *TableTemplate
}

FuncTemplate is a template item for a custom query.

type IdxTemplate

type IdxTemplate struct {
	Type        string
	Name        string
	TableSchema string
	TableName   string
	IndexName   string
	IsUnique    bool
	Plural      string
	Comment     string
	Fields      []*models.Column
	Table       *TableTemplate
}

IdxTemplate is a template item for a index into a table.

type ProcTemplate

type ProcTemplate struct {
	Name               string
	ReturnType         string
	NilReturnType      string
	TableSchema        string
	ProcName           string
	ProcParameterNames string
	ProcParameterTypes string
	ProcReturnType     string
	Comment            string
	Parameters         []*models.Column
}

ProcTemplate is a template item for a stored procedure.

type TableTemplate

type TableTemplate struct {
	Type            string
	TableSchema     string
	TableName       string
	PrimaryKey      string
	PrimaryKeyField string
	PrimaryKeyType  string
	Comment         string
	Fields          []*models.Column
}

TableTemplate is a template item for a table.

Jump to

Keyboard shortcuts

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