Conditional contact fields in the template

How can I set conditional contact fields in the template?

Something like:

{if contactfield=title == Frau}‍
Liebe {contactfield=firstname}‍
{elseif contactfield=title == Herr}‍
Lieber {contactfield=firstname}‍
{endif}

Here you go, step by step:

Thanks. Wow and it’s Twig. Very simple!