Documentation ¶
Index ¶
- func Add(a int, b int) int
- func Ago(t time.Time, formats ...string) string
- func Append(m []interface{}, args ...interface{}) []interface{}
- func Array(args ...interface{}) []interface{}
- func Blank(s string) bool
- func CSRF() got.HTML
- func CSV(s got.HTML) string
- func CentsToBase(p int64) string
- func CentsToPrice(p int64) string
- func CentsToPriceShort(p int64) string
- func CommaSeparatedArray(args []string) string
- func Contains(list []int64, item int64) bool
- func CreateMap(args ...interface{}) map[string]interface{}
- func Date(t time.Time, formats ...string) got.HTML
- func DateField(label string, name string, t time.Time, args ...string) got.HTML
- func Empty() map[string]interface{}
- func Escape(s string) string
- func EscapeURL(s string) string
- func Exists(s string) bool
- func Field(label string, name string, v interface{}, args ...string) got.HTML
- func HTML(s string) got.HTML
- func HTMLAttribute(s string) got.HTMLAttr
- func Int64(i int) int64
- func JSON(t string) got.HTML
- func JSONTime(t time.Time) got.HTML
- func Link(t string, u string, a ...string) got.HTML
- func Map(m map[string]interface{}, k string, v interface{}) map[string]interface{}
- func Mod(a int, b int) int
- func NumberToCommas(n int64) string
- func NumberToHuman(n int64) string
- func Odd(a int) bool
- func OptionsForSelect(value interface{}, options interface{}) got.HTML
- func PriceToCents(p string) int
- func PriceToCentsString(p string) string
- func Sanitize(s string) got.HTML
- func Script(name string) got.HTML
- func Select(label string, name string, value int64, options []Option) got.HTML
- func SelectArray(label string, name string, value interface{}, options interface{}) got.HTML
- func Set(m map[string]interface{}, k string, v interface{}) string
- func SetIf(m map[string]interface{}, k string, v interface{}, t bool) string
- func Strip(s string) got.HTML
- func Style(name string) got.HTML
- func Subtract(a int, b int) int
- func TextArea(label string, name string, v interface{}, args ...string) got.HTML
- func Time(time time.Time, formats ...string) got.HTML
- func Truncate(s string, l int64) string
- func URL(s string) got.URL
- func UTCDate(t time.Time) got.HTML
- func UTCNow() got.HTML
- func UTCTime(t time.Time) got.HTML
- func XMLPreamble() got.HTML
- func YearNow() got.HTML
- type Option
- type Selectable
- type SelectableOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
func Append(m []interface{}, args ...interface{}) []interface{}
Append all args to an array, and return that array
func Array ¶
func Array(args ...interface{}) []interface{}
Array takes a set of interface pointers as variadic args, and returns a single array
func CentsToBase ¶
CentsToBase converts cents to the base currency unit, preserving cent display, with no currency
func CentsToPrice ¶
CentsToPrice converts a price in pence to a human friendly price including currency unit At present it assumes the currency is pounds, it should instead take an optional param for currency or not include it at all
func CentsToPriceShort ¶
CentsToPriceShort converts a price in pence to a human friendly price abreviated (no pence)
func CommaSeparatedArray ¶
CommaSeparatedArray returns the values as a comma separated string
func CreateMap ¶
func CreateMap(args ...interface{}) map[string]interface{}
CreateMap - given a set of interface pointers as variadic args, generate and return a map to the values This is currently unused as we just use simpler Map add above to add to context
func Date ¶
Date returns a formatted date string given a time and optional format Date format layouts are for the date 2006-01-02
func Empty ¶
func Empty() map[string]interface{}
Empty returns an empty map[string]interface{} for use as a context
func HTMLAttribute ¶
HTMLAttribute returns a string (which must not contain user input) as go template HTMLAttr
func JSONTime ¶
JSONTime returns a formatted date string with format suitable for using in a json file
func Link ¶
Link returns got.HTML with an anchor link given text and URL required Attributes (if supplied) should not contain user input
func NumberToCommas ¶
NumberToCommas formats large numbers with commas the entire number is still represented
func NumberToHuman ¶
NumberToHuman formats large numbers for human consumption some preceision is lost, e.g. 1.3m rather than 130000001
func OptionsForSelect ¶
OptionsForSelect creates a select field given an array of keys and values in order
func PriceToCents ¶
PriceToCents converts a price string in human friendly notation (£45 or £34.40) to a price in pence as an int64
func PriceToCentsString ¶
PriceToCentsString returns a price in cents as a string for use in params
func Sanitize ¶
Sanitize the html, leaving only tags we consider safe (see the sanitize package for details and tests)
func SelectArray ¶
SelectArray creates a select field given an array of keys and values in order
func XMLPreamble ¶
XMLPreamble returns an XML preamble as got.HTML, primarily to work around a bug in html/template which escapes <? see https://github.com/golang/go/issues/12496
Types ¶
type Option ¶
type Option struct { Id int64 // The value - FIXME migrate to ID and use as interface Name string // The name }
Option type contains number and string
func (Option) ID ¶
ID returns the value for this select option as an int64 this is supplied in case of use in templates
func (Option) SelectName ¶
SelectName returns the public name for this select option
func (Option) SelectValue ¶
SelectValue returns the value for this select option
type Selectable ¶
Selectable provides an interface for options in a select
type SelectableOption ¶
SelectableOption provides a concrete implementation of Selectable - this should be called string option or similar
func NumberOptions ¶
func NumberOptions(args ...int64) []SelectableOption
NumberOptions creates an array of selectables, with an optional min and max value supplied as arguments
func StringOptions ¶
func StringOptions(args ...string) []SelectableOption
StringOptions creates an array of selectables from strings
func (SelectableOption) SelectName ¶
func (o SelectableOption) SelectName() string
SelectName returns the public name for this select option
func (SelectableOption) SelectValue ¶
func (o SelectableOption) SelectValue() string
SelectValue returns the value for this select option