Below are some global functions that are available in every template.
Version
version
- renders the version of kibble used
Kibble:{{ version }}
Lang
Returns an object describing the current language being rendered.
lang.Code
- the language code, e.g. en - Englishlang.Locale
- the language and locale. e.g. en-USlang.DefinitionFilePath
- the file to use for this languagelang.IsDefault
- true if this is the default language for the site
Language:{{ lang.Code }} -> Language:en
Path: {{ lang.DefinitionFilePath }} -> Path:en_AU.all.json
i18n
This function provides a means to localise the page to a specific language. This is done via a translation file.
File: en-US.all.json
{
"name": "A man needs a name",
"bundle_items_all_films": { "other": "{{.Count}} films" },
}
i18n - Simple case
i18n("name")
will search for "name"
in the language file and display the result.
{{ i18n("name") }} -> A man needs a name
i18n - Replacements
i18n("bundle_items_all_films", 2)
will search for the translation "bundle_items_all_films"
and pass the argument 2 into the count field.
i18n("bundle_items_all_films", 2) -> 2 films
Configuration
There are some configuration variables that are available to the site.
config("device_user_limit")
- this returns the number of devices that a user can have registered against their account.
configInt("device_user_limit", 0)
- this returns the number of devices that a user can have registered against their account as a number, or 0 if there is no value.