#StackBounty: #django #django-templates #pug #templatetags How to mix Pug/Jade with Django conditionals and html element attributes?

Bounty: 50

I want to write Django conditionals for html attributes, like

<a {% if item.link %} href="{{ item.link }}", target="_blank", rel="noopener", aria-label="{{ item }}" {% endif %}>
     --- Content ---
</a>

I am using pug/jade, so I can’t put jade/pug syntax inside “Content” block, the compiler breaks. I would like to know if I can handle that in any way to no repeat the “Content” block.

I tried also, withouth success:

a({% if item.link %} href="{{ item.link }}", target="_blank", rel="noopener", aria-label="{{ item }}" {% endif %})
      ----Content---


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.