title: Conditionals of dynamic content with PUG and FLASK
body: <p>This is the flask file.</p>
  
  <pre><code>from flask import render_template
  from app import app
  
  @app.route('/')
  @app.route('/index')
  def index():
      user = {'nickname': 'Miguel'}  # fake user
      return render_template('index.html',title='Home',user=user)
  </code></pre>
  
  <p>This is pug file:</p>
  
  <pre><code>doctype html
  html(lang="en")
      head
          title pageTitle
  
          if title
              title {{ title }} - microblog
          else if !title
              title Welcome to microblog1
          else
              title Welcome to microblog2
  
      body
      h1 Hello,  {{ user.nickname }}!
      if {{ user.nickname }} == "Miguel"
          h1 Miguel
  </code></pre>
  
  <p>This is what the index.html looks like once converted with Prepros:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;title&gt;pageTitle&lt;/title&gt;
          &lt;title&gt;Welcome to microblog1&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Hello,  {{ user.nickname }}!&lt;/h1&gt;
          &lt;h1&gt;{{ user.nickname }}&lt;/h1&gt;
          &lt;h1&gt;# user.nickname&lt;/h1&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I can get dynamic content from FLASK with my PUG file.
  So the following in the script works:</p>
  
  <pre><code>h1 Hello,  {{ user.nickname }}!
  </code></pre>
  
  <p>The output is "Hello, Miguel!"</p>
  
  <p>but this part doesn't work.</p>
  
  <pre><code>if {{ user.nickname }} == "Miguel"
          h1 Miguel
  </code></pre>
  
  <p>I get a syntax error: Unexpected token. So I can get the name from Flask, but I can't use it in an if statement?
  I'm not sure if I'm doings something wrong or if it's just not supported. 
  Btw, I'm using Prepros(which is giving the error) to convert my PUG file to HTML.</p>
  
  <p>Something that might be related is that when I do convert my file via Prepros, I don't really get the result I would expect.</p>
  
  <p>This is from the PUG file:</p>
  
  <pre><code>title pageTitle
  if title
      h1 {{ title }}
  else if !title
      title Welcome to microblog1
  </code></pre>
  
  <p>In the html I would expect:</p>
  
  <pre><code>&lt;title&gt;pageTitle&lt;/title&gt;
  {% if title %}
      &lt;title&gt;{{ title }}&lt;/title&gt;
  {% else if !title %}
      &lt;title&gt; Welcome to microblog1
  </code></pre>
  
  <p>but I end up with:</p>
  
  <pre><code>&lt;title&gt;pageTitle&lt;/title&gt;
  &lt;title&gt;Welcome to microblog1&lt;/title&gt;
  </code></pre>
  
  <p>It's as if Prepros answers the IF statement before converting to HTML. Which means the code is not dynamic. I'm new to both PUG and FLASK, so I'm not sure where to try find the solution.</p>