helper

package
v0.0.0-...-6e85089 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassifyLangFiles

func ClassifyLangFiles(fpaths []string) (map[string][]LanguageTplFile, error)

ClassifyLangFiles ...

func Glob

func Glob(dir string, ext string) ([]string, error)

Glob return all *.ext in dir recusively, and trim dir path

func MustJSONMarshal

func MustJSONMarshal(v interface{}) string

MustJSONMarshal json.Marshal must

Types

type FileHandler

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

FileHandler ...

func NewFileHandler

func NewFileHandler(fileHook langhook.FileHook) *FileHandler

NewFileHandler ...

func (*FileHandler) Close

func (h *FileHandler) Close() error

Close close all files

func (*FileHandler) GetFile

func (h *FileHandler) GetFile(path string) (*os.File, error)

GetFile gets *os.File by path, and cache it

type LanguageTplFile

type LanguageTplFile struct {
	NS       *NameSegment
	FilePath string
}

LanguageTplFile language file

type NameSegment

type NameSegment struct {
	DirPath      string
	FileName     string
	TemplateType string
	// 0 means all
	ObjectCount int
	FileExt     string
}

NameSegment segment for filename

func ParseNameSegment

func ParseNameSegment(fpath string) (*NameSegment, error)

ParseNameSegment parse NameSegment from dir/fname

type TemplateTool

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

Tool helper for

func NewTemplateTool

func NewTemplateTool(templateDir string, funcMap template.FuncMap) *TemplateTool

NewTool new tool for template

func (*TemplateTool) Execute

func (t *TemplateTool) Execute(w io.Writer, name string, obj interface{}) error

func (*TemplateTool) ExecuteCached

func (t *TemplateTool) ExecuteCached(w io.Writer, name string, obj interface{}) error

ExecuteCached executes a specified template in the template set using the supplied obj as its parameters and writing the output to w.

func (*TemplateTool) ExecuteRawString

func (t *TemplateTool) ExecuteRawString(w io.Writer, rawTpl string, obj interface{}) error

func (*TemplateTool) ExecuteRawStringToString

func (t *TemplateTool) ExecuteRawStringToString(rawTpl string, obj interface{}) (string, error)

Jump to

Keyboard shortcuts

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