bug 7706 quadruple execution
demonstrates that code in ${} gets run 4x instead of 1x.
by corydodt
HTML
<script src="https://github.com/jquery/jquery-tmpl/raw/master/jquery.tmpl.js"></script>
<script type="text/html" id="thingies">
<p>This doesn't happen if you use a function call:</p>
${c1()}
<h1>counter1 should be 1: <br> counter1=${counter1}</h1>
<br />
<p>But it does happen with any kind of naked expression:</p>
${(counter2++)?"":""}
<h1>counter2 should be 1: <br> counter2=${counter2}</h1>
<br />
<p>Just to show the ternary expression itself isn't the problem:</p>
<div style="color:#ccc">${counter2++}</div>
<h1>counter2 should be 2: <br> counter2=${counter2}</h1>
</script>
<span id="cursor" />
JavaScript
window.counter1 = window.counter2 = 0;
window.c1 = function () {counter1++;return ""};
$('#thingies').tmpl({}).insertBefore('#cursor');