Documentation ¶
Overview ¶
Package tmpl provides methods primarily used in html templates.
Index ¶
- func BoolSelectbox(selected *bool, name string) template.HTML
- func Checkbox(checked bool, name string) template.HTML
- func GetBoolSelectboxValue(val map[string][]string, index int, name string) *bool
- func GetFloat64Ptr(val map[string][]string, index int, name string) (*float64, error)
- func GetIntPtr(val map[string][]string, index int, name string) (*int, error)
- func GetLikelihood(r *http.Request, name string, index int, def string) string
- func GetListTextboxValue(val map[string][]string, index int, name string) []string
- func GetString(val map[string][]string, name string, index int, def string) string
- func LikelihoodMultiSelect(val string, name string, index int) template.HTML
- func ListTextbox(list []string, name, class string) template.HTML
- func NewMap(objs ...interface{}) map[string]interface{}
- func Selectbox(str, name string, opts ...string) template.HTML
- func TextboxOfFloat64Ptr(val *float64, name string) template.HTML
- func TextboxOfIntPtr(val *int, name string) template.HTML
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolSelectbox ¶
BoolSelectbox returns selectbox html text which including `true`, `false` and `undefined`, with a specified name.
selected argument specifies a option selected by default and if selected is nil, undefined should be selected by default.
func Checkbox ¶
Checkbox returns checkbox html text with a specified name. If checked is true, generated checkbox is checked by default.
func GetBoolSelectboxValue ¶
GetBoolSelectboxValue returns a boolean pointer from specified arguments, in which val is html form values a user sent.
This method has one-to-one relationship with BoolSelectBox and if the user selected `undefined`, this should return nil.
func GetFloat64Ptr ¶
GetFloat64Ptr returns a float pointer from corresponding user textbox input.
If the textbox is empty, this returns nil. If the user input is invalid, this returns an error.
func GetIntPtr ¶
GetIntPtr returns an integer pointer from corresponding user textbox input.
If the textbox is empty, this returns nil. If the user input is invalid, this returns an error.
func GetListTextboxValue ¶
GetListTextboxValue returns a string slice a user inputted into the corresponding list textbox.
val argument is html form values the user sent.
func GetString ¶
GetString just returns a string value from specified user html form input.
If there is no value corresponded to specified name and index, this returns def.
func LikelihoodMultiSelect ¶
func ListTextbox ¶
ListTextbox returns html text with specified initial list values and name.
func NewMap ¶
func NewMap(objs ...interface{}) map[string]interface{}
NewMap returns a map instance with specified arguments.
This goes into panic if the order of objs is not key-value one.
Example ¶
package main import ( "fmt" "github.com/iwataka/mybot/tmpl" ) func main() { m := tmpl.NewMap("key1", "val", "key2", 1) fmt.Println(m["key1"]) fmt.Println(m["key2"]) }
Output: val 1
func Selectbox ¶
Selectbox returns selectbox html text with specified name and options. str argument specifies default selected value in this selectbox.
func TextboxOfFloat64Ptr ¶
TextboxOfFloat64Ptr returns html textbox text with an initial value and name.
If val is nil, generated textbox has no default value.
Types ¶
This section is empty.