capitalize
This function accepts a string and converts its first character to uppercase.
Syntax
The function accepts two arguments.
Argument | Type | Description | Default value |
---|---|---|---|
string | String | The string to be transformed | — |
lowerOther | Boolean | Should other characters in the string be modified | true |
tip
lowerOther
determines what the function does with other characters in the string.If this argument is skipped or its value is set to true
:
- The first characters of all parts of the string delimited with hyphens are also converted to uppercase.
- All other characters are converted to lowercase.
This behavior can be turned off by setting this argument to false
.
In that case, all characters except for the first one are left unchanged.
lowerOther value | string value | Function return value |
---|---|---|
true | saint-denis | Saint-Denis |
true | aix-en-Provence | Aix-En-Provence |
false | saint-denis | Saint-denis |
false | aix-en-Provence | Aix-en-Provence |
How to use
This function is typically used for outputting personal, geographical, and other proper names.
require: name/nameEn.sc
module = sys.zb-common
theme: /
# ...
state: WhatIsYourName
a: What’s your name?
state: GetName
q: * $Name *
a: Nice to meet you, {{capitalize($parseTree._Name.name)}}!
tip
The example above relies on the name dictionary from the
zb-common
system module.