Skip to main content

capitalize

This function accepts a string and converts its first character to uppercase.

Syntax

The function accepts two arguments.

ArgumentTypeDescriptionDefault value
stringStringThe string to be transformed
lowerOtherBooleanShould other characters in the string be modifiedtrue
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 valuestring valueFunction return value
truesaint-denisSaint-Denis
trueaix-en-ProvenceAix-En-Provence
falsesaint-denisSaint-denis
falseaix-en-ProvenceAix-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.