If tag in Selmer (clojure templating engine similar to Django)

479 views Asked by At

I am trying to do an admin page for a webapp, displaying the status of a user ("User" or "Admin"). Here is an extract of the Selmer template I wrote:

<tbody>
{% for user in users %}
<tr>
    <td>{{user.admin}}</td>
    <td>{% if {{user.admin}} %}TRUE{% else %}FALSE{% endif %}</td>
</tr>
{% endfor %}
</tbody>

And here is the source code of the resulting page:

<tr>
    <td>true</td>
    <td>FALSE</td>
</tr>

<tr>
    <td>false</td>
    <td>FALSE</td>
</tr>

As you can see I would like the first FALSE to be TRUE instead. There must be something wrong with the way I am using "if"... can somebody help?

PS: here is the "users" map that is passed to Selmer :

{:users ({:email "[email protected]", :admin true} {:email "[email protected]", :admin false})}
1

There are 1 answers

0
Yogthos On

You've almost got it, but you don't have to use {{..}} inside a tag, so the if statement should look as follows:

{% if user.admin %}TRUE{% else %}FALSE{% endif %}