Back to godoc.org
flamingo.me/pugtemplate / templatefunctions

Package templatefunctions

v1.1.4
Latest Go to latest

The highest tagged major version is .

Published: Apr 3, 2020 | License: MIT | Module: flamingo.me/pugtemplate

Index

type AssetFunc

type AssetFunc struct {
	Router  *web.Router   `inject:""`
	Engine  *pugjs.Engine `inject:""`
	BaseURL string        `inject:"config:cdn.base_url,optional"`
}

AssetFunc returns the proper URL for the asset, either local or via CDN

func (*AssetFunc) Func

func (af *AssetFunc) Func(ctx context.Context) interface{}

Func as implementation of asset method

type CapitalizeFunc

type CapitalizeFunc struct{}

CapitalizeFunc struct

func (*CapitalizeFunc) Func

func (s *CapitalizeFunc) Func(ctx context.Context) interface{}

Func to make titleCase (CapitalizeFunc)

type DataFunc

type DataFunc struct {
	Router *web.Router `inject:""`
}

DataFunc allows templates to access the router's `get` method

func (*DataFunc) Func

func (g *DataFunc) Func(ctx context.Context) interface{}

Func as implementation of get method

type DebugFunc

type DebugFunc struct{}

DebugFunc renders data as JSON, which allows debugging in templates

func (DebugFunc) Func

func (df DebugFunc) Func(ctx context.Context) interface{}

Func as implementation of debug method

type EscapeHTMLFunc

type EscapeHTMLFunc struct{}

EscapeHTMLFunc is exported as a template function

func (*EscapeHTMLFunc) Func

func (f *EscapeHTMLFunc) Func(context.Context) interface{}

Func - templatefunction to escape html strings

type GetFunc

type GetFunc struct {
	Router *web.Router `inject:""`
}

GetFunc allows templates to access the router's `get` method

func (*GetFunc) Func

func (g *GetFunc) Func(ctx context.Context) interface{}

Func as implementation of get method

type JSON

type JSON struct{}

JSON is our Javascript's JSON equivalent

func (JSON) Parse

func (j JSON) Parse(x string) pugjs.Object

Parse Stringify parses a string and returns an object

func (JSON) Stringify

func (j JSON) Stringify(x interface{}) string

Stringify returns a string from the json

type JsJSON

type JsJSON struct{}

JsJSON is exported as a template function

func (JsJSON) Func

func (jl JsJSON) Func(ctx context.Context) interface{}

Func returns the JSON object

type JsMath

type JsMath struct{}

JsMath is exported as a template function

func (JsMath) Func

func (ml JsMath) Func(ctx context.Context) interface{}

Func as implementation of debug method

type JsObject

type JsObject struct{}

JsObject template function

func (JsObject) Func

func (ol JsObject) Func(ctx context.Context) interface{}

Func as implementation of debug method

type Math

type Math struct{}

Math is our Javascript's Math equivalent

func (Math) Ceil

func (m Math) Ceil(x interface{}) int

Ceil rounds a value up to the next biggest integer

func (Math) Max

func (m Math) Max(x ...interface{}) (res float64)

Max gets the maximum value

func (Math) Min

func (m Math) Min(x ...interface{}) (res float64)

Min gets the minimum value

func (Math) Round

func (m Math) Round(x interface{}) int

Round rounds a value to the nearest integer

func (Math) Trunc

func (m Math) Trunc(x interface{}) int

Trunc drops the decimals

type Object

type Object struct{}

Object implementation

func (Object) Assign

func (o Object) Assign(target *pugjs.Map, sources ...*pugjs.Map) pugjs.Object

Assign all properties from the sources to the target map

func (Object) Keys

func (o Object) Keys(obj interface{}) *pugjs.Array

Keys returns all keys of a map in lexical order

type ParseFloat

type ParseFloat struct{}

ParseFloat struct for template function

func (*ParseFloat) Func

func (p *ParseFloat) Func(ctx context.Context) interface{}

Func tries to parse any type into a float64, it is checking for pugjs types and also for regular types

type ParseInt

type ParseInt struct{}

ParseInt struct for template function

func (*ParseInt) Func

func (p *ParseInt) Func(ctx context.Context) interface{}

Func tries to parse any type into an integer, it is checking for pugjs types and also for regular types

type StartsWithFunc

type StartsWithFunc struct{}

StartsWithFunc struct

func (*StartsWithFunc) Func

func (s *StartsWithFunc) Func(ctx context.Context) interface{}

Func StartsWithFunc

type StriptagsFunc

type StriptagsFunc struct{}

StriptagsFunc provides template function to strip html tags

func (StriptagsFunc) Func

func (df StriptagsFunc) Func(ctx context.Context) interface{}

Func implements the strip tags template function

type TrimFunc

type TrimFunc struct{}

TrimFunc struct

func (*TrimFunc) Func

func (s *TrimFunc) Func(ctx context.Context) interface{}

Func - TrimFunc

type TruncateFunc

type TruncateFunc struct{}

TruncateFunc struct

func (*TruncateFunc) Func

func (s *TruncateFunc) Func(ctx context.Context) interface{}

Func TruncateFunc

type TryURLFunc

type TryURLFunc struct {
	Router *web.Router `inject:""`
}

TryURLFunc allows templates to access the routers `URL` helper method

func (*TryURLFunc) Func

func (u *TryURLFunc) Func(ctx context.Context) interface{}

Func as implementation of url method

type URLFunc

type URLFunc struct {
	Router    *web.Router     `inject:""`
	Logger    flamingo.Logger `inject:""`
	DebugMode bool            `inject:"config:debug.mode"`
}

URLFunc allows templates to access the routers `URL` helper method

func (*URLFunc) Func

func (u *URLFunc) Func(ctx context.Context) interface{}

Func as implementation of url method

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier