| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
</head> |
| 5 |
<body> |
| 6 |
<button id="start">Start</button> |
| 7 |
<button id="stop">Stop</button> |
| 8 |
|
| 9 |
<script type="text/javascript" src="../browser/nunjucks-dev.js"></script> |
| 10 |
<script> |
| 11 |
var tmpl = '<h1>{{ header }}</h1>' + |
| 12 |
'<h1>{{ header }}</h1>' + |
| 13 |
'{% if items.length %}' + |
| 14 |
'<ul>' + |
| 15 |
'{% for item in items %}' + |
| 16 |
' {% if item.current %}' + |
| 17 |
' <li><strong>{{ item.name }}</strong></li>' + |
| 18 |
' {% else %}' + |
| 19 |
' <li><a href="{{ item.url }}">{{ item.name }}</a></li>' + |
| 20 |
' {% endif %}' + |
| 21 |
'{% endfor %}' + |
| 22 |
'</ul>' + |
| 23 |
'{% else %}' + |
| 24 |
'<p>The list is empty.</p>' + |
| 25 |
'{% endif %}'; |
| 26 |
|
| 27 |
var env = new nunjucks.Environment(); |
| 28 |
var running = false; |
| 29 |
var timer = null; |
| 30 |
var t; |
| 31 |
|
| 32 |
function start() { |
| 33 |
for(var i=0; i<20000; i++) { |
| 34 |
t = new nunjucks.Template(tmpl, env, null, null, true); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
function stop() { |
| 39 |
if(timer) { |
| 40 |
timer && clearTimeout(timer); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
document.getElementById('start').addEventListener('click', function() { |
| 45 |
running = true; |
| 46 |
start(); |
| 47 |
}); |
| 48 |
document.getElementById('stop').addEventListener('click', stop); |
| 49 |
</script> |
| 50 |
</body> |
| 51 |
</html> |