render

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

html render like beego html template

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFuncMap added in v0.0.3

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

AddFuncMap let user to register a func in the template.

func AddTemplateExt added in v0.0.3

func AddTemplateExt(ext string)

AddTemplateExt add new extension for template.

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 added in v0.0.3

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 added in v0.0.3

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 added in v0.0.3

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 added in v0.0.3

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 added in v0.0.3

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 added in v0.0.3

type FileSystem struct{}

func (FileSystem) Open added in v0.0.3

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) NewHTMLRender added in v0.2.1

func (m HTMLRender) NewHTMLRender(dir string, funcMap template.FuncMap, delims Delims, autoRender bool, runMode string) Render

NewHTMLRender return a Render interface

func (HTMLRender) Render

func (m HTMLRender) Render(w http.ResponseWriter, name string, data interface{}) error

Render

func (HTMLRender) WriteContentType

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

type Render

type Render interface {
	Render(w http.ResponseWriter, name string, data interface{}) 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