Answers.Body: <p>The problem is that the space in the if-statement is <code>&amp;nbsp;</code> rather than a normal space. For this reason, it's worth writing your smarty statements while viewing the Source code in the template editor.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-31T17:29:30.967Z
Answers.LastActivityDate: 2017-10-31T17:29:30.967Z
Answers.UserDisplayName: Phil Morice Brubaker
Body: <p>Writing as a self-answered question since it may help others...</p>
  
  <p>I am adding smarty code to a mail template. Including:</p>
  
  <p><code>{capture assign=designation}{contribution.contribution_source}{/capture}</code></p>
  
  <p>Later in the page, I call the variable as such:</p>
  
  <p><code>{if&nbsp;$designation}, for {contribution.contribution_source}{/if}</code></p>
  
  <p>But the template breaks when I try to use it. The code looks good as far as I can tell. What's the problem?</p>
  
Tags: <message-templates><smarty>
Title: Smarty code not working
ThreadText: # Smarty code not working
  
  (Asked by: username_0 on 2017-10-31)
  
  Writing as a self-answered question since it may help others...
  
  I am adding smarty code to a mail template. Including:
  
  `{capture assign=designation}{contribution.contribution_source}{/capture}`
  
  Later in the page, I call the variable as such:
  
  `{if $designation}, for {contribution.contribution_source}{/if}`
  
  But the template breaks when I try to use it. The code looks good as far as I can tell. What's the problem?
  
  **Tags:** message-templates, smarty
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-10-31. Score: 3 | Accepted answer
  
  The problem is that the space in the if-statement is  rather than a normal space. For this reason, it's worth writing your smarty statements while viewing the Source code in the template editor.
  
  
  ---
  
  