Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make Jade stop HTML encoding element attributes, and produce a literal string value?
    primarykey
    data
    text
    <p><strong>UPDATE</strong> Jade v0.24.0 fixes this with a <code>!=</code> syntax for attributes. <code>option(value!='&lt;%= id %&gt;')</code></p> <hr> <p>I'm trying to build an <code>&lt;option&gt;</code> with jade, where the value of the option is an UnderscoreJS template marker: <code>&lt;%= id %&gt;</code> but I can't get it to work because jade is converting my marker text to <code>&amp;lt;= id &amp;gt;</code>.</p> <p>Here's my Jade markup:</p> <pre class="lang-js prettyprint-override"><code>script(id="my-template", type="text/template") select(id="type") &amp;lt;% _.each(deviceTypes, function(type){ %&gt; option(value='&amp;lt;%= type.id %&gt;') &lt;%= type.name %&gt; &amp;lt;% }) %&gt; </code></pre> <p>I expect it to produce this html:</p> <pre class="lang-html prettyprint-override"><code>&lt;script id="my-template" type="text/template"&gt; &lt;select id='type'&gt; &lt;% _.each(deviceTypes, function(type){ %&gt; &lt;option value="&lt;%= type.id %&gt;"&gt; &lt;%= type.name %&gt; &lt;/option&gt; &lt;% }) %&gt; &lt;/select&gt; &lt;/script&gt; </code></pre> <p>But what I get instead, is this:</p> <pre class="lang-html prettyprint-override"><code>&lt;script id="my-template" type="text/template"&gt; &lt;select id='type'&gt; &lt;% _.each(deviceTypes, function(type){ %&gt; &lt;option value="&amp;lt;%= type.id %&amp;gt;"&gt; &lt;%= type.name %&gt; &lt;/option&gt; &lt;% }) %&gt; &lt;/select&gt; &lt;/script&gt; </code></pre> <p>Note the very subtle difference in the <code>&lt;option&gt;</code> line of the output... the <code>value</code> attribute of the option has been HTML encoded.</p> <p>How do I prevent Jade from HTML encoding this value? I need it to produce the literal value, the same way it does with the text of the option.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload