-
Notifications
You must be signed in to change notification settings - Fork 53
Script: ToNickname
SamuelPlentz edited this page Jul 2, 2022
·
4 revisions
This script allows to combine nickname and firstname into one placeholder, using the firstname as fallback if the nickname is not defined. There is a variant of this script called ToFirstOrLastname.
var data = this.mQuicktext.process_to(mVariables);
// use name if nickname is not available
if(typeof data['nickname'] == 'undefined') {
data['nickname'] = [];
}
for(var i = 0; i < data['firstname'].length; i++) {
if(typeof data['nickname'][i] == 'undefined') {
data['nickname'][i] = data['firstname'][i];
}
}
if(typeof data['nickname'] != 'undefined') {
if(mVariables.length < 1) mVariables[0] = ", ";
return data['nickname'].join(mVariables[0].replace(/\\n/g, "\n").replace(/\\t/g, "\t"));
} else return "";
Assuming you want to write an email to your good friends Samuel (nickname Sam) and David (no nickname).
Using this script in your template:
Hello [[SCRIPT=ToNickname|, hello ]],
would resolve to:
Hello Sam, hello David,