render

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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, funcMap template.FuncMap, delims Delims, files ...string) error

BuildTemplate init template

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 FileExists

func FileExists(name string) bool

FileExists reports whether the named file or directory exists.

func HTML2str

func HTML2str(html string) string

HTML2str

func InSlice

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

InSlice checks given string in string slice or not.

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 Str2html

func Str2html(str string) template.HTML

func Substr

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

Substr Substr

Types

type Delims

type Delims struct {
	Left  string
	Right string
}

Delims Delims

type HTMLRender

type HTMLRender struct {
	Template *template.Template
	Name     string
	Data     interface{}
}

HTMLRender a simple html render

func (HTMLRender) Instance

func (r HTMLRender) Instance(name string, data interface{}) Render

func (HTMLRender) Render

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

Render (HTML) executes template and writes its result with custom ContentType for response.

func (HTMLRender) WriteContentType

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

WriteContentType (HTML) writes HTML ContentType.

type Render

type Render interface {
	// Render writes data with custom ContentType.
	Render(http.ResponseWriter) error
	// WriteContentType writes custom ContentType.
	WriteContentType(w http.ResponseWriter)

	Instance(name string, data interface{}) Render
}

Render interface is to be implemented by JSON, XML, HTML, YAML and so on.

Jump to

Keyboard shortcuts

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