β“˜ Changes are on the way!
Braze Bonfire is read-only from April 6–April 13, 2026. 

Braze Bonfire is getting an upgrade. From April 6 through April 13, 2026, Bonfire will be read-only while we tinker behind the scenes to improve your experience in the community. Read more.

Google Tag Manager

Forum Discussion

DavidO's avatar
DavidO
Visionary
2 years ago
Solved

Has anyone got 'map' and 'join' to work on a liquid array? Code review please :)

Hi all I have been looking at options to capitalize the first letter of both names for users who have two first names saved in our database. For example: 'tony peter' becomes 'Tony Peter'. I ca...
  • Arso's avatar
    2 years ago

    DavidO map only works on properties and the property name should be where you have 'capitalize' in teh code. 'capitalize' is not a property of any item in your array, that's why this won't work. 

    Try this:

    {% assign fullName = "tony peter" %}
    {% assign names = fullName | split: ' '  %}
    {%- capture capitalizedNames -%}
      {%- for name in names %}{{ name | capitalize }} {% endfor -%}
    {%- endcapture -%}
    {{ capitalizedNames }}