How can I link E-Mail greetings/Postal greetings to "formal" or "informal" communication style?
If you're talking about CiviMail message templates I think this is very similar to this question, maybe even a duplicate. You need to use {capture} and then put the captured variable in your if statement.