Documentation ¶
Index ¶
- Constants
- func BuildExtraFuncs(r *Renderer) template.FuncMap
- func RegistBuiltinTemplate(typeName string, templateSetName string, templateContent string)
- func RegistType(typeName string, obj interface{}, handler Handler)
- type Appendable
- type ColumnList
- type Handler
- type Indexer
- type PkgName
- type Renderer
- type Scope
- type Scopes
- type StringList
- type StringsContainer
- type TypeAdapter
- type TypeName
- type UniqueStringList
Constants ¶
const ( RootTemplateSetName = "" DefaultTemplateSetName = "default" )
Variables ¶
This section is empty.
Functions ¶
func BuildExtraFuncs ¶
func RegistBuiltinTemplate ¶
RegistBuiltinTemplate regist a builtin template for a type with the given name.
func RegistType ¶
RegistType regist a type for renderring.
Types ¶
type Appendable ¶
type Appendable interface {
Append(items ...interface{}) error
}
Appendable represents a mutable list of items.
type ColumnList ¶
type ColumnList struct {
// contains filtered or unexported fields
}
func NewColumnList ¶
func NewColumnList() *ColumnList
func (*ColumnList) Append ¶
func (cl *ColumnList) Append(items ...interface{}) error
func (*ColumnList) Cols ¶
func (cl *ColumnList) Cols() []*context.ColumnMeta
func (*ColumnList) Index ¶
func (cl *ColumnList) Index(i int) interface{}
func (*ColumnList) Len ¶
func (cl *ColumnList) Len() int
type Handler ¶
Handler takes a renderer and an object (TableMeta/SelectStmt...) as parameters, returns an object (the 'dot' object) for template renderring.
type PkgName ¶
type PkgName struct { // Full import path, empty if it's builtin or in current package. PkgPath string // contains filtered or unexported fields }
PkgName represents a package used in source code.
type Renderer ¶
type Renderer struct { // Global context. *context.Context // Which file is renderring. *Scopes // Go type adapter. *TypeAdapter // Extra functions used in templates. ExtraFuncs template.FuncMap // Map type -> (template set name -> template). Templates map[reflect.Type]map[string]*template.Template // Use which set of templates for renderring. // Find the first of TemplateSetName/DefaultTemplateSetName/RootTemplateSetName // to render. TemplateSetName string }
Renderer contain information to render objects.
func NewRenderer ¶
NewRenderer create Renderer from Context.
func (*Renderer) AddTemplate ¶
func (r *Renderer) AddTemplate(typeName string, templateSetName string, templateContent string) error
AddTemplate add a template (in a template set ) for a type.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Used to store information in a (file) scope.
type Scopes ¶
type Scopes struct {
// contains filtered or unexported fields
}
Set of Scope.
func (*Scopes) CreatePkgName ¶
func (*Scopes) CreateTypeName ¶
func (*Scopes) CreateTypeNameFromSpec ¶
Create TypeName from dot-seperated spec:
[pkgPath.]type
Example:
"[]byte" "sql.NullString" "github.com/go-sql-driver/mysql.NullTime"
func (*Scopes) SwitchScope ¶
Switch to a (file) scope.
type StringList ¶
type StringList struct {
// contains filtered or unexported fields
}
StringList is just a list of strings.
func NewStringList ¶
func NewStringList() *StringList
func (*StringList) Append ¶
func (sl *StringList) Append(items ...interface{}) error
func (*StringList) Index ¶
func (sl *StringList) Index(i int) interface{}
func (*StringList) Len ¶
func (sl *StringList) Len() int
func (*StringList) Strings ¶
func (sl *StringList) Strings() []string
type StringsContainer ¶
type StringsContainer interface {
Strings() []string
}
StringsContainer represents a list of strings.
type TypeAdapter ¶
For adapting database type and go type.
func NewTypeAdapter ¶
func NewTypeAdapter(scopes *Scopes) *TypeAdapter
type TypeName ¶
type TypeName struct { // The pkg containing the type. *PkgName // Name of the type. TypeName string }
TypeName represents a type used in source code.
type UniqueStringList ¶
type UniqueStringList struct {
// contains filtered or unexported fields
}
UniqueStringList is a list of unique strings.
func NewUniqueStringList ¶
func NewUniqueStringList(converter func(string) string, default_ string) *UniqueStringList
func (*UniqueStringList) Append ¶
func (usl *UniqueStringList) Append(items ...interface{}) error
func (*UniqueStringList) Index ¶
func (usl *UniqueStringList) Index(i int) interface{}
func (*UniqueStringList) Len ¶
func (usl *UniqueStringList) Len() int
func (*UniqueStringList) Strings ¶
func (usl *UniqueStringList) Strings() []string