Interpolating values in HTML attributes - Pug (Jade)
<p>I am trying to construct an <code>anchor</code> tag with a dynamic <code>href</code> attribute in Jade.</p>
<p>I did go through the <a href="http://jade-lang.com/reference/interpolation/" rel="nofollow noreferrer">docs</a> and some SO questions but they didn't help me. This is what I tried.</p>
<pre><code>a(href= &quot;http://www.imdb.com/title/#{movie.imdb_id}&quot;) Know more
</code></pre>
<p>But it renders</p>
<pre><code>http://www.imdb.com/title/#{movie.imdb_id}  
</code></pre>
<p>rather than</p>
<pre><code>http://www.imdb.com/title/tt1234567
</code></pre>
<p>However this works</p>
<pre><code>a(href= &quot;http://www.imdb.com/title/&quot; + movie.imdb_id) Know more
</code></pre>
<p>and this too.</p>
<pre><code>- var url = &quot;http://www.imdb.com/title/&quot; + movie.imdb_id;
  a(href= url) Know more
</code></pre>
<p>What's wrong with the first version?</p>