Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From the <a href="http://underscorejs.org/#template" rel="noreferrer">fine manual</a>:</p> <blockquote> <p>By default, <strong>template</strong> places the values from your data in the local scope via the <code>with</code> statement.</p> </blockquote> <p>You can see what's going on using the compiled template's <code>source</code> property:</p> <pre><code>​var t = _.template('&lt;%= v %&gt;'); console.log(t.source);​​​​​​​​​​​​​​​​​​​ </code></pre> <p>gives you (tweaked for clarity):</p> <pre><code>function(obj) { var __t, __p = ''; with(obj || {}) { __p += '' + ((__t = ( v )) == null ? '' : __t) + ''; } return __p; } </code></pre> <p>The <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/with" rel="noreferrer"><code>with</code></a> is the source of your problem:</p> <blockquote> <p>JavaScript looks up an unqualified name by searching a scope chain associated with the execution context of the script or function containing that unqualified name. The 'with' statement adds the given object to the head of this scope chain during the evaluation of its statement body. If an unqualified name used in the body matches a property in the scope chain, then the name is bound to the property and the object containing the property. Otherwise a 'ReferenceError' is thrown.</p> </blockquote> <p>So given this:</p> <pre><code>with(obj) { console.log(pancakes) } </code></pre> <p>JavaScript will first look for <code>obj.pancakes</code> and if there is no <code>pancakes</code> property in <code>obj</code>, it will look for <code>pancakes</code> in the global scope. Apparently IE has a <code>window.description</code> value which represents one of the page's <code>&lt;meta&gt;</code> tags. Using your own namespace inside the template (as in the work-around) sort of negates what <code>with</code> does and keeps you from getting to the global <code>window</code> properties.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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