tplfunc

package
v0.0.0-...-800783e Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2016 Wenhui Shen <www.webx.top>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var TplFuncMap template.FuncMap = template.FuncMap{
	"Now":             Now,
	"Eq":              Eq,
	"Add":             Add,
	"Sub":             Sub,
	"IsNil":           IsNil,
	"Html":            Html,
	"Js":              Js,
	"Css":             Css,
	"HtmlAttr":        HtmlAttr,
	"ToHtmlAttrs":     ToHtmlAttrs,
	"ElapsedMemory":   com.ElapsedMemory,
	"TotalRunTime":    com.TotalRunTime,
	"CaptchaForm":     CaptchaForm,
	"FormatByte":      com.FormatByte,
	"FormatPastTime":  com.FormatPastTime,
	"DateFormat":      com.DateFormat,
	"DateFormatShort": com.DateFormatShort,
	"Replace":         strings.Replace,
	"Contains":        strings.Contains,
	"HasPrefix":       strings.HasPrefix,
	"HasSuffix":       strings.HasSuffix,
	"Split":           strings.Split,
	"Join":            strings.Join,
	"Str":             com.Str,
	"Int":             com.Int,
	"Int32":           com.Int32,
	"Int64":           com.Int64,
	"Float32":         com.Float32,
	"Float64":         com.Float64,
	"InSlice":         com.InSlice,
	"InSliceI":        com.InSliceIface,
	"Substr":          com.Substr,
	"StripTags":       com.StripTags,
	"Default":         Default,
	"JsonEncode":      com.SetJson,
	"Set":             Set,
	"Append":          Append,
	"Nl2br":           NlToBr,
}

Functions

func Add

func Add(left interface{}, right interface{}) interface{}

func Append

func Append(renderArgs map[string]interface{}, key string, value interface{}) string

func CaptchaForm

func CaptchaForm(args ...string) template.HTML

验证码表单域

func CaptchaVerify

func CaptchaVerify(captchaSolution string, r *http.Request) bool

验证码验证

func Css

func Css(raw string) template.CSS

func Default

func Default(defaultV interface{}, v interface{}) interface{}

func Eq

func Eq(left interface{}, right interface{}) bool

func Html

func Html(raw string) template.HTML

func HtmlAttr

func HtmlAttr(raw string) template.HTMLAttr

func IsNil

func IsNil(a interface{}) bool

func Js

func Js(raw string) template.JS

func Nl2br

func Nl2br(text string) string

将换行符替换为<br />

func NlToBr

func NlToBr(text string) template.HTML

Replaces newlines with <br />

func Now

func Now() time.Time

func Set

func Set(renderArgs map[string]interface{}, key string, value interface{}) string

func Sub

func Sub(left interface{}, right interface{}) interface{}

func ToHtmlAttrs

func ToHtmlAttrs(raw map[string]interface{}) (r map[template.HTMLAttr]interface{})

Types

type Static

type Static struct {
	RootPath        string //根路径:相对于本程序的路径,本程序读取时需要
	Path            string //网址访问的路径
	CombineJs       bool
	CombineCss      bool
	CombineSavePath string //合并文件保存路径,首尾均不带斜杠
	Combined        map[string][]string
	Combines        map[string]bool
	// contains filtered or unexported fields
}

func NewStatic

func NewStatic(staticPath, rootPath string) *Static

func (*Static) ClearCache

func (s *Static) ClearCache()

func (*Static) CssTag

func (s *Static) CssTag(staticFiles ...string) template.HTML

func (*Static) CssUrl

func (s *Static) CssUrl(staticFile string) (r string)

func (*Static) DeleteCombined

func (s *Static) DeleteCombined(url string)

func (*Static) ImgTag

func (s *Static) ImgTag(staticFile string, attrs ...string) template.HTML

func (*Static) ImgUrl

func (s *Static) ImgUrl(staticFile string) (r string)

func (*Static) IsCombined

func (s *Static) IsCombined(combineUrl string) (ok bool)

func (*Static) JsTag

func (s *Static) JsTag(staticFiles ...string) template.HTML

func (*Static) JsUrl

func (s *Static) JsUrl(staticFile string) (r string)

func (*Static) OnUpdate

func (s *Static) OnUpdate(tmplDir string) func(string)

func (*Static) RecordCombined

func (s *Static) RecordCombined(fromUrl string, combineUrl string)

func (*Static) RecordCombines

func (s *Static) RecordCombines(combineUrl string)

func (*Static) Register

func (s *Static) Register(funcMap map[string]interface{}) map[string]interface{}

func (*Static) StaticUrl

func (s *Static) StaticUrl(staticFile string) (r string)

Jump to

Keyboard shortcuts

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