Documentation ¶
Overview ¶
模板文件和路径处理包
模板文件系统、模板文件路径修正器、模板主题配置
Index ¶
- Constants
- func IsThemeName(s string) bool
- func NewFileSystemTrimPrefix(trimPrefix string, fs http.FileSystem) http.FileSystem
- func NewManager(mgr driver.Manager, pa PathAliases) driver.Manager
- func NewMultiManager(templateDir string, managers ...driver.Manager) driver.Manager
- func NewStaticDir(dir string, trimPrefix ...string) http.FileSystem
- func RGB2Hex(rgb string) string
- type FileInfo
- type FileSystems
- func (f FileSystems) IsEmpty() bool
- func (f FileSystems) Open(name string) (file http.File, err error)
- func (f FileSystems) ReadDir(name string) (dirs []fs.FileInfo, err error)
- func (f FileSystems) ReadFile(name string) (content []byte, err error)
- func (f *FileSystems) Register(fileSystem http.FileSystem)
- func (f FileSystems) Size() int
- func (f FileSystems) Stat(name string) (fi fs.FileInfo, err error)
- type MultiManager
- func (b *MultiManager) AddAllow(allows ...string)
- func (b *MultiManager) AddCallback(rootDir string, callback func(name, typ, event string))
- func (b *MultiManager) AddIgnore(ignores ...string)
- func (b *MultiManager) AddWatchDir(ppath string) (err error)
- func (b *MultiManager) CancelWatchDir(oldDir string) (err error)
- func (b *MultiManager) ChangeWatchDir(oldDir string, newDir string) (err error)
- func (b *MultiManager) ClearAllows()
- func (b *MultiManager) ClearCache()
- func (b *MultiManager) ClearCallback()
- func (b *MultiManager) ClearIgnores()
- func (b *MultiManager) Close()
- func (b *MultiManager) DelAllow(allow string)
- func (b *MultiManager) DelCallback(rootDir string)
- func (b *MultiManager) DelIgnore(ignore string)
- func (b *MultiManager) GetManagers() []driver.Manager
- func (b *MultiManager) GetTemplate(filename string) (content []byte, err error)
- func (b *MultiManager) HasBindata() bool
- func (b *MultiManager) SetLogger(logger logger.Logger)
- func (b *MultiManager) SetTemplate(filename string, content []byte) error
- func (b *MultiManager) Start() error
- func (b *MultiManager) TemplateDir() string
- type PathAliases
- func (p *PathAliases) Add(alias, absPath string) *PathAliases
- func (p *PathAliases) AddAllSubdir(absPath string) error
- func (p *PathAliases) Aliases() []string
- func (p *PathAliases) Parse(withAliasTagPath string) string
- func (p *PathAliases) ParseOk(withAliasTagPath string) (string, bool)
- func (p *PathAliases) ParsePrefix(withAliasPrefixPath string) string
- func (p *PathAliases) ParsePrefixOk(withAliasPrefixPath string) (string, bool)
- func (p *PathAliases) Range(fn func(string, string) error) (err error)
- func (p *PathAliases) Restore(fullpath string) string
- func (p *PathAliases) RestoreOk(fullpath string) (string, bool)
- func (p *PathAliases) RestorePrefix(fullpath string) string
- func (p *PathAliases) RestorePrefixOk(fullpath string) (string, bool)
- func (p *PathAliases) TmplDirs() []string
- type PathFixer
- type PathFixers
- func (p *PathFixers) Add(dirName string, fixer PathFixer) *PathFixers
- func (p *PathFixers) AddDir(dirName string, parentPath string) *PathFixers
- func (p *PathFixers) Delete(names ...string) *PathFixers
- func (p *PathFixers) Fix(ctx echo.Context, t *Template, theme string, tmpl string) (string, bool)
- func (p *PathFixers) Keys() []string
- func (p *PathFixers) MakeFixer(parentPath string) PathFixer
- type PathHandle
- type SortFileInfoByFileType
- type StaticDir
- type Storer
- type Template
- func (t *Template) AddAlias(alias, tmplDir string) *Template
- func (t *Template) AddAliasFromAllSubdir(tmplDir string) *Template
- func (t *Template) Aliases() []string
- func (t *Template) ApplyAliases() *Template
- func (t *Template) ClearCache()
- func (t *Template) Fix(ctx echo.Context, _ http.FileSystem, theme string, tmpl string) (string, bool)
- func (t *Template) Handle(ctx echo.Context, theme string, tmpl string) string
- func (t *Template) Register(renderer driver.Driver, watchOtherDirs ...string)
- func (t *Template) SetCustomFS(fs http.FileSystem) *Template
- func (t *Template) SetEnableTheme(enable bool) *Template
- func (t *Template) SetHandler(h PathHandle) *Template
- func (t *Template) SetPathFixers(h *PathFixers) *Template
- func (t *Template) SetStorer(storer Storer) *Template
- func (t *Template) SetThemeInfo(c echo.Context, v *ThemeInfo)
- func (t *Template) SetTmplDir(tmplDir string) *Template
- func (t *Template) Storer() Storer
- func (t *Template) ThemeInfo(c echo.Context) *ThemeInfo
- func (t *Template) TmplDirs() []string
- type ThemeAuthor
- type ThemeColor
- type ThemeColors
- type ThemeInfo
- func (t *ThemeInfo) AsLite() ThemeInfoLite
- func (t *ThemeInfo) ColorName() string
- func (t *ThemeInfo) Decode(b []byte) error
- func (t *ThemeInfo) DecodeFile(file string) error
- func (t *ThemeInfo) Embed() bool
- func (t *ThemeInfo) Encode() []byte
- func (t *ThemeInfo) EncodeToFile(destFile string) error
- func (t *ThemeInfo) HasColorName(colorName string, notDefault ...bool) bool
- func (t *ThemeInfo) HasForm(templateName string) bool
- func (t *ThemeInfo) IsColorName(colorName string) bool
- func (t *ThemeInfo) Render(templateName string) template.HTML
- func (t *ThemeInfo) SaveForm(ctx echo.Context, templateName string, ...) error
- func (t *ThemeInfo) SetEmbed() *ThemeInfo
- type ThemeInfoLite
Constants ¶
View Source
const ( KindBackend = `backend` KindFrontend = `frontend` )
Variables ¶
This section is empty.
Functions ¶
func IsThemeName ¶ added in v0.3.0
func NewFileSystemTrimPrefix ¶ added in v0.3.0
func NewFileSystemTrimPrefix(trimPrefix string, fs http.FileSystem) http.FileSystem
func NewManager ¶
func NewManager(mgr driver.Manager, pa PathAliases) driver.Manager
NewManager 新建模板文件系统管理驱动实例
func NewMultiManager ¶ added in v0.3.0
func NewStaticDir ¶ added in v0.3.0
func NewStaticDir(dir string, trimPrefix ...string) http.FileSystem
Types ¶
type FileSystems ¶ added in v0.3.0
type FileSystems []http.FileSystem
func NewFileSystems ¶ added in v0.3.0
func NewFileSystems() FileSystems
func (FileSystems) IsEmpty ¶ added in v0.3.0
func (f FileSystems) IsEmpty() bool
func (FileSystems) Open ¶ added in v0.3.0
func (f FileSystems) Open(name string) (file http.File, err error)
func (FileSystems) ReadDir ¶ added in v0.3.0
func (f FileSystems) ReadDir(name string) (dirs []fs.FileInfo, err error)
func (FileSystems) ReadFile ¶ added in v0.3.0
func (f FileSystems) ReadFile(name string) (content []byte, err error)
func (*FileSystems) Register ¶ added in v0.3.0
func (f *FileSystems) Register(fileSystem http.FileSystem)
func (FileSystems) Size ¶ added in v0.3.0
func (f FileSystems) Size() int
type MultiManager ¶ added in v0.3.0
type MultiManager struct {
// contains filtered or unexported fields
}
func (*MultiManager) AddAllow ¶ added in v0.3.0
func (b *MultiManager) AddAllow(allows ...string)
func (*MultiManager) AddCallback ¶ added in v0.3.0
func (b *MultiManager) AddCallback(rootDir string, callback func(name, typ, event string))
func (*MultiManager) AddIgnore ¶ added in v0.3.0
func (b *MultiManager) AddIgnore(ignores ...string)
func (*MultiManager) AddWatchDir ¶ added in v0.3.0
func (b *MultiManager) AddWatchDir(ppath string) (err error)
func (*MultiManager) CancelWatchDir ¶ added in v0.3.0
func (b *MultiManager) CancelWatchDir(oldDir string) (err error)
func (*MultiManager) ChangeWatchDir ¶ added in v0.3.0
func (b *MultiManager) ChangeWatchDir(oldDir string, newDir string) (err error)
func (*MultiManager) ClearAllows ¶ added in v0.3.0
func (b *MultiManager) ClearAllows()
func (*MultiManager) ClearCache ¶ added in v0.3.0
func (b *MultiManager) ClearCache()
func (*MultiManager) ClearCallback ¶ added in v0.3.0
func (b *MultiManager) ClearCallback()
func (*MultiManager) ClearIgnores ¶ added in v0.3.0
func (b *MultiManager) ClearIgnores()
func (*MultiManager) Close ¶ added in v0.3.0
func (b *MultiManager) Close()
func (*MultiManager) DelAllow ¶ added in v0.3.0
func (b *MultiManager) DelAllow(allow string)
func (*MultiManager) DelCallback ¶ added in v0.3.0
func (b *MultiManager) DelCallback(rootDir string)
func (*MultiManager) DelIgnore ¶ added in v0.3.0
func (b *MultiManager) DelIgnore(ignore string)
func (*MultiManager) GetManagers ¶ added in v0.3.0
func (b *MultiManager) GetManagers() []driver.Manager
func (*MultiManager) GetTemplate ¶ added in v0.3.0
func (b *MultiManager) GetTemplate(filename string) (content []byte, err error)
func (*MultiManager) HasBindata ¶ added in v0.3.0
func (b *MultiManager) HasBindata() bool
func (*MultiManager) SetLogger ¶ added in v0.3.0
func (b *MultiManager) SetLogger(logger logger.Logger)
func (*MultiManager) SetTemplate ¶ added in v0.3.0
func (b *MultiManager) SetTemplate(filename string, content []byte) error
func (*MultiManager) Start ¶ added in v0.3.0
func (b *MultiManager) Start() error
func (*MultiManager) TemplateDir ¶ added in v0.3.0
func (b *MultiManager) TemplateDir() string
type PathAliases ¶
type PathAliases struct {
// contains filtered or unexported fields
}
PathAliases 模板路径别名分组设置
func (*PathAliases) AddAllSubdir ¶
func (p *PathAliases) AddAllSubdir(absPath string) error
AddAllSubdir 添加某个路径下以子文件夹为别名的路径(用于添加各个子文件夹为不同主题模板的情况)
func (*PathAliases) Parse ¶
func (p *PathAliases) Parse(withAliasTagPath string) string
Parse 根据中括号别名前缀解析模板路径为实际存在的真实路径
func (*PathAliases) ParseOk ¶
func (p *PathAliases) ParseOk(withAliasTagPath string) (string, bool)
ParseOk 根据中括号别名前缀解析模板路径为实际存在的真实路径
func (*PathAliases) ParsePrefix ¶
func (p *PathAliases) ParsePrefix(withAliasPrefixPath string) string
ParsePrefix 根据模板路径子文件夹为别名解析模板路径为实际存在的真实路径
func (*PathAliases) ParsePrefixOk ¶
func (p *PathAliases) ParsePrefixOk(withAliasPrefixPath string) (string, bool)
ParsePrefixOk 根据模板路径子文件夹为别名解析模板路径为实际存在的真实路径
func (*PathAliases) Range ¶
func (p *PathAliases) Range(fn func(string, string) error) (err error)
Range 遍历全部别名及其模板文件夹路径
func (*PathAliases) Restore ¶
func (p *PathAliases) Restore(fullpath string) string
Restore 还原真实路径为带中括号别名前缀的模板初始路径
func (*PathAliases) RestoreOk ¶
func (p *PathAliases) RestoreOk(fullpath string) (string, bool)
RestoreOk 还原真实路径为带中括号别名前缀的模板初始路径
func (*PathAliases) RestorePrefix ¶
func (p *PathAliases) RestorePrefix(fullpath string) string
RestorePrefix 还原真实路径为模板初始路径
func (*PathAliases) RestorePrefixOk ¶
func (p *PathAliases) RestorePrefixOk(fullpath string) (string, bool)
RestorePrefixOk 还原真实路径为模板初始路径
type PathFixers ¶ added in v0.3.0
func (*PathFixers) Add ¶ added in v0.3.0
func (p *PathFixers) Add(dirName string, fixer PathFixer) *PathFixers
func (*PathFixers) AddDir ¶ added in v0.3.0
func (p *PathFixers) AddDir(dirName string, parentPath string) *PathFixers
func (*PathFixers) Delete ¶ added in v0.3.0
func (p *PathFixers) Delete(names ...string) *PathFixers
func (*PathFixers) Keys ¶ added in v0.3.0
func (p *PathFixers) Keys() []string
func (*PathFixers) MakeFixer ¶ added in v0.3.0
func (p *PathFixers) MakeFixer(parentPath string) PathFixer
type PathHandle ¶ added in v0.3.0
type SortFileInfoByFileType ¶ added in v0.3.0
type SortFileInfoByFileType []FileInfo
func (SortFileInfoByFileType) Len ¶ added in v0.3.0
func (s SortFileInfoByFileType) Len() int
func (SortFileInfoByFileType) Less ¶ added in v0.3.0
func (s SortFileInfoByFileType) Less(i, j int) bool
func (SortFileInfoByFileType) Swap ¶ added in v0.3.0
func (s SortFileInfoByFileType) Swap(i, j int)
type StaticDir ¶ added in v0.3.0
type StaticDir struct {
// contains filtered or unexported fields
}
type Storer ¶ added in v0.3.0
type Storer interface { Put(echo.Context, string, *ThemeInfo) error Get(echo.Context, string) (*ThemeInfo, error) }
func NewFileStore ¶ added in v0.3.0
type Template ¶ added in v0.3.0
type Template struct { TmplDir string Kind string PathAliases *PathAliases *PathFixers // contains filtered or unexported fields }
func New ¶ added in v0.3.0
func New(kind string, pa *PathAliases, registerToGroup ...bool) *Template
func (*Template) AddAliasFromAllSubdir ¶ added in v0.3.0
func (*Template) ApplyAliases ¶ added in v0.3.0
func (*Template) ClearCache ¶ added in v0.3.0
func (t *Template) ClearCache()
func (*Template) SetCustomFS ¶ added in v0.3.0
func (t *Template) SetCustomFS(fs http.FileSystem) *Template
func (*Template) SetEnableTheme ¶ added in v0.3.0
func (*Template) SetHandler ¶ added in v0.3.0
func (t *Template) SetHandler(h PathHandle) *Template
func (*Template) SetPathFixers ¶ added in v0.3.0
func (t *Template) SetPathFixers(h *PathFixers) *Template
func (*Template) SetThemeInfo ¶ added in v0.3.0
func (*Template) SetTmplDir ¶ added in v0.3.0
type ThemeAuthor ¶ added in v0.3.0
type ThemeColor ¶ added in v0.3.0
type ThemeColor struct { Name string `json:"name,omitempty"` // 颜色英文名(用于调用相应颜色的css文件) Title string `json:"title,omitempty"` // 颜色中文标题 IsDefault bool `json:"isDefault,omitempty"` // 是否为默认颜色 Color string `json:"color,omitempty"` // 颜色值 PreviewImage string `json:"previewImage,omitempty"` // 预览图 }
func (ThemeColor) HexColor ¶ added in v0.3.0
func (t ThemeColor) HexColor() string
type ThemeColors ¶ added in v0.3.0
type ThemeColors []ThemeColor
type ThemeInfo ¶ added in v0.3.0
type ThemeInfo struct { Author ThemeAuthor `json:"author,omitempty"` // 模板作者 Colors ThemeColors `json:"colors,omitempty"` // 多种颜色主题时,所有支持的颜色信息 Version string `json:"version,omitempty"` // 版本号(格式: 1.0.0) Name string `json:"name"` // 主题英文名 Title string `json:"title"` // 主题中文标题 UpdatedAt string `json:"updatedAt,omitempty"` // 更新时间(格式: 2006-01-02 15:04:05) Description string `json:"description,omitempty"` // 简介 PreviewImage string `json:"previewImage,omitempty"` // 预览图 PreviewURL string `json:"previewURL,omitempty"` // 预览网址 CustomConfig echo.H `json:"customConfig,omitempty"` // 可自定义配置的数据 FormConfig map[string]formConfig.Config `json:"formConfig,omitempty"` // 表单配置 Fallback []string `json:"fallback,omitempty"` // 兜底主题 // contains filtered or unexported fields }
ThemeInfo 模板主题信息
func GetThemeInfoFromContext ¶ added in v0.3.0
func NewThemeInfo ¶ added in v0.3.0
func NewThemeInfo() *ThemeInfo
func (*ThemeInfo) AsLite ¶ added in v0.3.0
func (t *ThemeInfo) AsLite() ThemeInfoLite
func (*ThemeInfo) DecodeFile ¶ added in v0.3.0
func (*ThemeInfo) EncodeToFile ¶ added in v0.3.0
func (*ThemeInfo) HasColorName ¶ added in v0.3.0
func (*ThemeInfo) IsColorName ¶ added in v0.3.0
type ThemeInfoLite ¶ added in v0.3.0
Click to show internal directories.
Click to hide internal directories.