Skip to main content Link Search Menu Expand Document Toggle dark mode Copy Code (external link)

toUpper() : Convert to Uppercase

Convert a string to uppercase letters.


On this page

Signature

toUpper(str)

Parameters

Parameter Type Required Description
str String Yes The string to convert

Returns

Type: String

The string converted to uppercase.


Examples

Basic Uppercase

<p>{{toUpper(model.text)}}</p>

Data:

doc.Params["model"] = new {
    text = "hello world"
};

Output:

<p>HELLO WORLD</p>

Headers and Titles

<h1>{{toUpper(model.title)}}</h1>

Data:

doc.Params["model"] = new {
    title = "Important Notice"
};

Output:

<h1>IMPORTANT NOTICE</h1>

Product Codes

<p>SKU: {{toUpper(model.sku)}}</p>

Data:

doc.Params["model"] = new {
    sku = "wdg-12345-a"
};

Output:

<p>SKU: WDG-12345-A</p>

Capitalize First Letter

<p>{{toUpper(substring(model.name, 0, 1))}}{{substring(model.name, 1)}}</p>

Data:

doc.Params["model"] = new {
    name = "john doe"
};

Output:

<p>John doe</p>

Emphasis

{{#each model.alerts}}
  <div class="alert">
    <strong>{{toUpper(this.level)}}</strong>: {{this.message}}
  </div>
{{/each}}

Data:

doc.Params["model"] = new {
    alerts = new[] {
        new { level = "warning", message = "Low disk space" },
        new { level = "error", message = "Connection failed" }
    }
};

Output:

<div class="alert">
  <strong>WARNING</strong>: Low disk space
</div>
<div class="alert">
  <strong>ERROR</strong>: Connection failed
</div>

Notes

  • Converts all lowercase letters to uppercase
  • Leaves numbers and special characters unchanged
  • Culture-dependent (uses current culture)
  • Useful for headings and emphasis
  • Does not modify the original value
  • For lowercase, use toLower()

See Also