tplbeego

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

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 adds a new path to the supported view paths. Can later be used by setting a controller ViewPath to this folder will panic if called after beego.Run()

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 Compare

func Compare(a, b interface{}) (equal bool)

Compare is a quick and dirty comparison function. It will convert whatever you give it to strings and see if the two values are equal. Whitespace is trimmed. Used by the template parser as "eq".

func CompareNot

func CompareNot(a, b interface{}) (equal bool)

CompareNot !Compare

func Date

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

Date takes a PHP like date func to Go's time format.

func DateFormat

func DateFormat(t time.Time, layout string) (datestring string)

DateFormat takes a time and a layout string and returns a string with the formatted date. Used by the template parser as "dateformat"

func DateParse

func DateParse(dateString, format string) (time.Time, error)

DateParse Parse Date use PHP time format.

func ExecuteTemplate

func ExecuteTemplate(wr io.Writer, name 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, 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 returns escaping text convert from html.

func HasTemplateExt

func HasTemplateExt(paths string) bool

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

func Htmlquote

func Htmlquote(text string) string

Htmlquote returns quoted html string.

func Htmlunquote

func Htmlunquote(text string) string

Htmlunquote returns unquoted html string.

func MapGet

func MapGet(arg1 interface{}, arg2 ...interface{}) (interface{}, error)

MapGet getting value from map by keys usage:

Data["m"] = M{
    "a": 1,
    "1": map[string]float64{
        "c": 4,
    },
}

{{ map_get m "a" }} // return 1 {{ map_get m 1 "c" }} // return 4

func NotNil

func NotNil(a interface{}) (isNil bool)

NotNil the same as CompareNot

func ParseForm

func ParseForm(form url.Values, obj interface{}) error

ParseForm will parse form values to struct via tag.

func Register

func Register() common.Caller

func RenderForm

func RenderForm(obj interface{}) template.HTML

RenderForm will render object to form html. obj must be a struct pointer.

func SetTemplateFSFunc

func SetTemplateFSFunc(fnt templateFSFunc)

SetTemplateFSFunc set default filesystem function

func Str2html

func Str2html(raw string) template.HTML

Str2html Convert string to template.HTML type.

func Substr

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

Substr returns the substr from start to length.

func URLFor

func URLFor(endpoint string, values ...interface{}) string

URLFor returns url string with another registered controller handler with params.

	usage:

	URLFor(".index")
	print URLFor("index")
 router /login
	print URLFor("login")
	print URLFor("login", "next","/"")
 router /profile/:username
	print UrlFor("profile", ":username","John Doe")
	result:
	/
	/login
	/login?next=/
	/user/John%20Doe

 more detail http://beego.me/docs/mvc/controller/urlbuilding.md

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 CallerCfg

type CallerCfg struct {
	Debug         bool
	TplExt        string
	ViewPath      string
	TemplateLeft  string
	TemplateRight string
}

func Config

func Config() CallerCfg

type CallerMuses

type CallerMuses struct {
	Tpl CallerTpl `toml:"tpl"`
}

type CallerTpl

type CallerTpl struct {
	TplBeego CallerCfg `toml:"tplBeego"`
}

type Cfg

type Cfg struct {
	Muses CallerMuses `toml:"muses"`
}

type FileSystem

type FileSystem struct {
}

func (FileSystem) Open

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

type Tmpl

type Tmpl struct {
	// context data
	Data map[interface{}]interface{}

	// template data
	TplName        string
	ViewPath       string
	Layout         string
	LayoutSections map[string]string // the key is the section name and the value is the template name
	TplPrefix      string
	TplExt         string
	// contains filtered or unexported fields
}

func Caller

func Caller() (obj *Tmpl, err error)

func (*Tmpl) Init

func (c *Tmpl) Init(tplExt, viewPath string)

Init generates default values of controller operations.

func (*Tmpl) RenderBytes

func (c *Tmpl) RenderBytes() ([]byte, error)

RenderBytes returns the bytes of rendered template string. Do not send out response.

func (*Tmpl) SetTplPath

func (c *Tmpl) SetTplPath(tplPath string)

Jump to

Keyboard shortcuts

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