html

package
v0.0.0-...-4ecb35b Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b int) int

Add adds the numbers

func CSS

func CSS(s string) template.CSS

CSS prevents any custom embedded styles from being encoded to html safe values

func Checked

func Checked(checked interface{}) template.HTMLAttr

Checked returns the checked attribute for positive values.

<input type="checkbox" {{IsAdmin | checked}}> => <input type="checkbox" checked="checked">

func Disabled

func Disabled(obj interface{}) template.HTMLAttr

Disabled returns the checked attribute for positive values.

<button type="submit" {{HasError | disabled}}>Save</button> => <button type="submit" disabled="">Save</button>
or
<button type="submit" {{ValidationError | disabled}}>Save</button> => <button type="submit" disabled="">Save</button>

func EncodeKey

func EncodeKey(data interface{}) string

EncodeKey encodes a datastore key

func EncodeParentKey

func EncodeParentKey(key *datastore.Key) string

EncodeParentKey encodes the key's parent

func Hide

func Hide(display bool) template.CSS

func KeyEqual

func KeyEqual(a, b *datastore.Key) bool

KeyEqual allow for *datastore.Key comparison

func Markdown

func Markdown(input string) interface{}

Markdown converts text in the markdown syntax to html

func Preview

func Preview(size int, val string) string

Preview returns a preview of the string

func Selected

func Selected(selected bool) template.HTMLAttr

func Show

func Show(display bool) template.CSS

Show returns an empty style attr or display:none

<div {{IsVisibe | show}}> => <div style="display:none">some hidden text</div>

func Timestamp

func Timestamp(d time.Time) string

Timestamp formats the time to the RFC3339 layout

func ToErrorList

func ToErrorList(in interface{}) template.HTML

ToErrorList can be added to the template FuncMap to format the error output.

// handler
myTemplate.executeTemplate(w, "layout", template.FuncMap{
    "error": ToErrorList,
})

<!-- HTML -->
<form ...>
    {{ .Error | error }}
</form>

Types

type Errors

type Errors struct {
	// contains filtered or unexported fields
}

Errors allows multiple errors to be contained within a single error, which simplifies returning validation errors to the client.

func (Errors) Add

func (e Errors) Add(err error)

Add appends the error to the list

func (Errors) Error

func (e Errors) Error() error

type Page

type Page map[string]interface{}

Page is the container for data passed to the html form

func NewPage

func NewPage() Page

NewPage creates a new page

func NewPageWithCSRFToken

func NewPageWithCSRFToken(r *http.Request) Page

NewPageWithCSRFToken create a page with an initialized CSRF token

func (Page) Set

func (p Page) Set(key string, val interface{})

Set sets the key and value

func (Page) SetError

func (p Page) SetError(err interface{})

SetError sets any error that needs to be shown

func (Page) SetUser

func (p Page) SetUser(user interface{}, _ ...interface{})

SetUser sets the current user

Jump to

Keyboard shortcuts

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