Search code examples
javascripthtmlmustachetitle-case

How do i capitalize a variable in mustache


I have this variable in my mustache template called type, i want to capitalise the value of type using title case, is this possible ? taking into consideration that type is not what is displayed on the web page, it stores a value.

{{type}}


Solution

  • You can wrap it in a span and use CSS.

    CSS

    .capitalize {
        text-transform: capitalize;
    }
    

    Template

    <span class="capitalize">{{type}}</span>