Release announcements, helpful tips, and community discussion

Tip: Initials in signatures

A client asked:

How can I just use the initial of a worker’s last name in their signature?

Our templating language is based on Twig, which includes a handy syntax for extracting substrings from text:

{{"this is a string"[start:length]}}

  • start specifies the character to start from, with the first position being 0.
  • length specifies how many characters to extract.

So you could display the first initial of a worker’s last name using:

{% set first_name = "Kina" %}
{% set last_name = "Halpue" %}
{{first_name}} {{last_name[0:1]}}

Which would output:

Kina H

You can also do things like:

{% set first_name = "Kina" %}
{% set last_name = "Halpue" %}

{# Shortcut for the first letter #}

{# Everything except for the first letter #}

{# The last three letters #}

Which outputs: