systopia / de.systopia.moregreetings

CiviCRM Extension for additional greetings
GNU Affero General Public License v3.0
4 stars 10 forks source link

New custom smarty function tokens_have_min_length #23

Closed bjendres closed 1 year ago

bjendres commented 3 years ago

For a specialised use case, we want to add the following custom smarty function: tokens_have_min_length. The idea is that it breaks down the input string into tokens using a "split" string, and then checking if all of the tokens have at least a length of X. If you want to check only some tokens, you can also provide a list of indices to check.

Usage: {if $contact.first_name|tokens_have_min_length:' ':2}

Additionally, we would like to add a function to extract a single element after tokenising: token_extract

Usage: {$contact.first_name|token_extract:" ":0} - extract the first part of the first name split by a space

jensschuppe commented 1 year ago

Released with 1.1.0.