Skip to content

Instantly share code, notes, and snippets.

@andrew-serrano
Created August 12, 2019 21:51
Show Gist options
  • Save andrew-serrano/538cb85bca8c945f32ab05754cb6703f to your computer and use it in GitHub Desktop.
Save andrew-serrano/538cb85bca8c945f32ab05754cb6703f to your computer and use it in GitHub Desktop.
Convert snake case value to title case
<mvt:comment>
Null the current status value
</mvt:comment>
<mvt:assign name="l.final_outputted_value" value="''" />
<mvt:comment>
Substring placeholder
</mvt:comment>
<mvt:assign name="l.substring" value="'placeholder'" />
<mvt:comment>
Current token position
</mvt:comment>
<mvt:assign name="l.position" value="1" />
<mvt:comment>
While get token is returning a substring continue
</mvt:comment>
<mvt:while expr="NOT ISNULL l.substring">
<mvt:comment>
Return substring
</mvt:comment>
<mvt:assign name="l.substring" value="gettoken( l.delimited_string, '_', l.position)" />
<mvt:comment>
Concat custom order status. Each custom order status will be snake case
and will be formatted to be title case. For example, "order_processing" -> "Order Processing"
</mvt:comment>
<mvt:assign name="l.final_outputted_value" value="l.final_outputted_value $ toupper(substring( l.substring, 1, 1 )) $ substring( l.substring, 2, len_var(l.substring)) $ ' '" />
<mvt:comment>
Increment position index
</mvt:comment>
<mvt:assign name="l.position" value="l.position + 1" />
</mvt:while>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment