mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-25 05:42:26 +00:00
parent
700d531a2c
commit
647540d0ef
1 changed files with 16 additions and 5 deletions
|
@ -97,18 +97,29 @@ func (l *Language) SetParam(k string, v interface{}) {
|
||||||
l.params[strings.ToLower(k)] = v
|
l.params[strings.ToLower(k)] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBool returns the value associated with the key as a boolean.
|
||||||
func (l *Language) GetBool(key string) bool { return cast.ToBool(l.Get(key)) }
|
func (l *Language) GetBool(key string) bool { return cast.ToBool(l.Get(key)) }
|
||||||
|
|
||||||
|
// GetString returns the value associated with the key as a string.
|
||||||
func (l *Language) GetString(key string) string { return cast.ToString(l.Get(key)) }
|
func (l *Language) GetString(key string) string { return cast.ToString(l.Get(key)) }
|
||||||
|
|
||||||
|
// GetInt returns the value associated with the key as an int.
|
||||||
func (l *Language) GetInt(key string) int { return cast.ToInt(l.Get(key)) }
|
func (l *Language) GetInt(key string) int { return cast.ToInt(l.Get(key)) }
|
||||||
|
|
||||||
func (ml *Language) GetStringMap(key string) map[string]interface{} {
|
// GetStringMap returns the value associated with the key as a map of interfaces.
|
||||||
return cast.ToStringMap(ml.Get(key))
|
func (l *Language) GetStringMap(key string) map[string]interface{} {
|
||||||
|
return cast.ToStringMap(l.Get(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetStringMapString returns the value associated with the key as a map of strings.
|
||||||
func (l *Language) GetStringMapString(key string) map[string]string {
|
func (l *Language) GetStringMapString(key string) map[string]string {
|
||||||
return cast.ToStringMapString(l.Get(key))
|
return cast.ToStringMapString(l.Get(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get returns a value associated with the key relying on pecified language.
|
||||||
|
// Get is case-insensitive for a key.
|
||||||
|
//
|
||||||
|
// Get returns an interface. For a specific value use one of the Get____ methods.
|
||||||
func (l *Language) Get(key string) interface{} {
|
func (l *Language) Get(key string) interface{} {
|
||||||
if l == nil {
|
if l == nil {
|
||||||
panic("language not set")
|
panic("language not set")
|
||||||
|
|
Loading…
Reference in a new issue