The CiviCRM doumentation describes, how to use Smarty to customize templates for mails and pdf's:
https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/#smarty
E.g.:
{capture assign=gift}{contact.custom_16}{/capture}
{if $gift == Yes}
This membership is a gift from {contact.custom_17}.
{/if}
Or:
{capture assign=Anredestil}{contact.communication_style}{/capture}
<br/>vielen Dank für
{if $Anredestil eq 'Du'}Deine{else}Ihre{/if}
However, in certain conditions (especially but not limited to CiviCRM on Wordpress), this creates fatal errors like:
PHP Fatal error: Smarty error: [in string:<p>{capture assign=Anredestil}Du{/capture}<
br />vielen Dank f&uuml;r {if $Anredestil eq &quot;Du&quot;}Deine{else}Ihre{/if} Spende.</p> line 1]: syntax error: (secure mode) 'quot' not allowed in if statement (Smarty_Compiler.class.php, line 1399) in /html/wordpress/wp-content/plugins/c
ivicrm/civicrm/packages/Smarty/Smarty.class.php on line 1100
An obvious solution might be, to deactived the "secure mode" - however, this might create an unsafe situation.