tpl

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2015 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After

func After(index interface{}, seq interface{}) (interface{}, error)

After is exposed to templates, to iterate over all the items after N in a rangeable list. It's meant to accompany First

func Apply

func Apply(seq interface{}, fname string, args ...interface{}) (interface{}, error)

Apply, given a map, array, or slice, returns a new slice with the function fname applied over it.

func Base64Decode

func Base64Decode(content interface{}) (string, error)

func Base64Encode

func Base64Encode(content interface{}) (string, error)

func Chomp

func Chomp(text interface{}) (string, error)

func DateFormat

func DateFormat(layout string, v interface{}) (string, error)

DateFormat converts the textual representation of the datetime string into the other form or returns it of the time.Time value. These are formatted with the layout string

func Delimit

func Delimit(seq, delimiter interface{}, last ...interface{}) (template.HTML, error)

func Dictionary

func Dictionary(values ...interface{}) (map[string]interface{}, error)

func Eq

func Eq(x, y interface{}) bool

func ExecuteTemplate

func ExecuteTemplate(context interface{}, buffer *bytes.Buffer, layouts ...string)

func ExecuteTemplateToHTML

func ExecuteTemplateToHTML(context interface{}, layouts ...string) template.HTML

func First

func First(limit interface{}, seq interface{}) (interface{}, error)

First is exposed to templates, to iterate over the first N items in a rangeable list.

func Ge

func Ge(a, b interface{}) bool

func GetCSV

func GetCSV(sep string, urlParts ...string) [][]string

GetCSV expects a data separator and one or n-parts of a URL to a resource which can either be a local or a remote one. The data separator can be a comma, semi-colon, pipe, etc, but only one character. If you provide multiple parts for the URL they will be joined together to the final URL. GetCSV returns nil or a slice slice to use in a short code.

func GetJSON

func GetJSON(urlParts ...string) interface{}

GetJSON expects one or n-parts of a URL to a resource which can either be a local or a remote one. If you provide multiple parts they will be joined together to the final URL. GetJSON returns nil or parsed JSON to use in a short code.

func Gt

func Gt(a, b interface{}) bool

func Highlight

func Highlight(in interface{}, lang, opts string) template.HTML

func In

func In(l interface{}, v interface{}) bool

func Intersect

func Intersect(l1, l2 interface{}) (interface{}, error)

func IsSet

func IsSet(a interface{}, key interface{}) bool

func Last

func Last(limit interface{}, seq interface{}) (interface{}, error)

Last is exposed to templates, to iterate over the last N items in a rangeable list.

func Le

func Le(a, b interface{}) bool

func Lt

func Lt(a, b interface{}) bool

func Markdownify

func Markdownify(text string) template.HTML

func Mod

func Mod(a, b interface{}) (int64, error)

func ModBool

func ModBool(a, b interface{}) (bool, error)

func Ne

func Ne(x, y interface{}) bool

func Partial

func Partial(name string, context_list ...interface{}) template.HTML

func ReadDir

func ReadDir(path string) []os.FileInfo

func Ref

func Ref(page interface{}, ref string) template.HTML

func RelRef

func RelRef(page interface{}, ref string) template.HTML

func Replace

func Replace(a, b, c interface{}) (string, error)

Replace all occurences of b with c in a

func ReturnWhenSet

func ReturnWhenSet(a, k interface{}) interface{}

func SafeCSS

func SafeCSS(text string) template.CSS

func SafeHTML

func SafeHTML(a string) template.HTML

func SafeHTMLAttr

func SafeHTMLAttr(text string) template.HTMLAttr

"safeHTMLAttr" is currently disabled, pending further discussion on its use case. 2015-01-19

func SafeJS

func SafeJS(a string) template.JS

SafeJS returns the given string as a template.JS type from html/template.

func SafeURL

func SafeURL(text string) template.URL

func Slicestr

func Slicestr(a interface{}, startEnd ...interface{}) (string, error)

Slicing in Slicestr is done by specifying a half-open range with two indices, start and end. 1 and 4 creates a slice including elements 1 through 3. The end index can be omitted, it defaults to the string's length.

func Sort

func Sort(seq interface{}, args ...interface{}) (interface{}, error)

func Split

func Split(a interface{}, delimiter string) ([]string, error)

func Substr

func Substr(a interface{}, nums ...interface{}) (string, error)

Substr extracts parts of a string, beginning at the character at the specified position, and returns the specified number of characters.

It normally takes two parameters: start and length. It can also take one parameter: start, i.e. length is omitted, in which case the substring starting from start until the end of the string will be returned.

To extract characters from the end of the string, use a negative start number.

In addition, borrowing from the extended behavior described at http://php.net/substr, if length is given and is negative, then that many characters will be omitted from the end of string.

func Trim

func Trim(a interface{}, b string) (string, error)

Trim leading/trailing characters defined by b from a

func Where

func Where(seq, key interface{}, args ...interface{}) (r interface{}, err error)

Types

type GoHTMLTemplate

type GoHTMLTemplate struct {
	template.Template
	// contains filtered or unexported fields
}

func (*GoHTMLTemplate) AddAceTemplate

func (t *GoHTMLTemplate) AddAceTemplate(name, basePath, innerPath string, baseContent, innerContent []byte) error

func (*GoHTMLTemplate) AddInternalShortcode

func (t *GoHTMLTemplate) AddInternalShortcode(name, content string) error

func (*GoHTMLTemplate) AddInternalTemplate

func (t *GoHTMLTemplate) AddInternalTemplate(prefix, name, tpl string) error

func (*GoHTMLTemplate) AddTemplate

func (t *GoHTMLTemplate) AddTemplate(name, tpl string) error

func (*GoHTMLTemplate) AddTemplateFile

func (t *GoHTMLTemplate) AddTemplateFile(name, baseTemplatePath, path string) error

func (*GoHTMLTemplate) EmbedShortcodes

func (t *GoHTMLTemplate) EmbedShortcodes()

func (*GoHTMLTemplate) EmbedTemplates

func (t *GoHTMLTemplate) EmbedTemplates()

func (*GoHTMLTemplate) GenerateTemplateNameFrom

func (t *GoHTMLTemplate) GenerateTemplateNameFrom(base, path string) string

func (*GoHTMLTemplate) LoadEmbedded

func (t *GoHTMLTemplate) LoadEmbedded()

func (*GoHTMLTemplate) LoadTemplates

func (t *GoHTMLTemplate) LoadTemplates(absPath string)

func (*GoHTMLTemplate) LoadTemplatesWithPrefix

func (t *GoHTMLTemplate) LoadTemplatesWithPrefix(absPath string, prefix string)

func (*GoHTMLTemplate) PrintErrors

func (t *GoHTMLTemplate) PrintErrors()

type Template

type Template interface {
	ExecuteTemplate(wr io.Writer, name string, data interface{}) error
	Lookup(name string) *template.Template
	Templates() []*template.Template
	New(name string) *template.Template
	LoadTemplates(absPath string)
	LoadTemplatesWithPrefix(absPath, prefix string)
	AddTemplate(name, tpl string) error
	AddAceTemplate(name, basePath, innerPath string, baseContent, innerContent []byte) error
	AddInternalTemplate(prefix, name, tpl string) error
	AddInternalShortcode(name, tpl string) error
	PrintErrors()
}

func InitializeT

func InitializeT() Template

InitializeT resets the internal template state to its initial state

func New

func New() Template

New returns a new Hugo Template System with all the additional features, templates & functions

func T

func T() Template

The "Global" Template System

type Tmpl

type Tmpl struct {
	Name string
	Data string
}

Jump to

Keyboard shortcuts

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