render

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

from beego template link: github.com/astaxie/beego/fs.go

from beego template link: github.com/astaxie/beego/template.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFuncMap

func AddFuncMap(key string, fn interface{}) error

AddFuncMap let user to register a func in the template.

func AddTemplateExt

func AddTemplateExt(ext string)

AddTemplateExt add new extension for template.

func AddViewPath

func AddViewPath(viewPath string) error

AddViewPath AddViewPath

func AssetsCSS

func AssetsCSS(text string) template.HTML

AssetsCSS returns stylesheet link tag with src string.

func AssetsJs

func AssetsJs(text string) template.HTML

AssetsJs returns script tag with src string.

func BuildTemplate

func BuildTemplate(dir string, files ...string) error

BuildTemplate will build all template files in a directory. it makes beego can render any template file in view directory.

func DateFormat

func DateFormat(t time.Time) string

DateFormat 日期格式化

func DateTimeFormat

func DateTimeFormat(t time.Time, format string) string

DateTimeFormat 格式化时间显示 format = "YYYY-MM-DD HH:mm:ss" or "YYYY年MM月DD日"

func ExecuteTemplate

func ExecuteTemplate(wr io.Writer, name, viewPath string, runMode string, data interface{}) error

ExecuteTemplate applies the template with name to the specified data object, writing the output to wr. A template will be executed safely in parallel.

func ExecuteViewPathTemplate

func ExecuteViewPathTemplate(wr io.Writer, name string, viewPath string, runMode string, data interface{}) error

ExecuteViewPathTemplate applies the template with name and from specific viewPath to the specified data object, writing the output to wr. A template will be executed safely in parallel.

func HTML2str

func HTML2str(html string) string

HTML2str

func HasTemplateExt

func HasTemplateExt(paths string) bool

HasTemplateExt return this path contains supported template extension of beego or not.

func InSlice

func InSlice(v string, sl []string) bool

func IntDate

func IntDate(val int64) (ret string)

IntDate 时间戳的日期格式化

func IntDateTime

func IntDateTime(val int64) (ret string)

IntDateTime return datetime string format ="YYYY-MM-DD HH:mm:ss"

func IntDateTimeFormat

func IntDateTimeFormat(val int64, format string) (ret string)

DateTimeFormat return datetime string format ="YYYY-MM-DD HH:mm:ss" or format ="YYYY-MM-DD HH:mm"

func SetTemplateFSFunc

func SetTemplateFSFunc(fnt templateFSFunc)

SetTemplateFSFunc set default filesystem function

func Str2html

func Str2html(str string) template.HTML

Str2html str2 to html code

func Substr

func Substr(s string, start, length int) string

Substr Substr

func Walk

func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error

Walk walks the file tree rooted at root in filesystem, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn.

Types

type Delims

type Delims struct {
	Left  string
	Right string
}

Delims template delims

type FileSystem

type FileSystem struct{}

func (FileSystem) Open

func (d FileSystem) Open(name string) (http.File, error)

type HTMLRender

type HTMLRender struct {
	ViewPath   string
	Name       string
	AutoRender bool
	FuncMap    template.FuncMap
	Data       interface{}
	Delims     Delims
	RunMode    string
}

HTMLRender a simple html render

func (HTMLRender) Instance

func (m HTMLRender) Instance(dir, name string, funcMap template.FuncMap, delims Delims, autoRender bool, runMode string, data interface{}) Render

Instance

func (HTMLRender) Render

func (m HTMLRender) Render(w http.ResponseWriter) error

Render

func (HTMLRender) WriteContentType

func (m HTMLRender) WriteContentType(w http.ResponseWriter)

type Render

type Render interface {
	Render(w http.ResponseWriter) error
	WriteContentType(w http.ResponseWriter)
}

Render interface is to be implemented by HTML

Jump to

Keyboard shortcuts

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