Conditional token pattern
Here is an idea, which I have not tried yet.

Sometimes you have tokens in combination with text formats. E.g. in commerce_checkout_completion_message_pane_checkout_form() the token replacement happens first, before the text format is applied. I am not sure if I agree with this order, but in this case it gives us some interesting options.

You could define a custom text filter which detects and evaluates markup like this:

{if true}hello{else}goodbye{endif}


and then you can use tokens to insert the true/false.

{if [token-which-returns-true-or-false]}hello{else}goodbye{endif}


This still leaves a lot in the open. Most tokens do not produce true/false, so maybe instead you want real equation formulas. But it is a direction you can explore further.