0

This is My JavaScript code: a simple demo of Qweb template

<script src="./static/lib/jquery/jquery.js"></script>
<script type="text/javascript" src="qweb2.js"></script>

<script>
    QWeb = new QWeb2.Engine();
    QWeb.add_template('test.xml');

    console.log(QWeb);
    console.log(QWeb.templates);
    console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');

</script>

And here is the result in chrome console:

enter image description here

Why is console.log(Qweb.templates) returning an empty object?

Smern
  • 18,746
  • 21
  • 72
  • 90
figol
  • 11
  • 2
  • I can not explain this issue; Js is so strange; – figol Jun 13 '15 at 15:41
  • Can you recreate it in codepen or somewhere? – Stefan Dimov Jun 13 '15 at 15:45
  • 1
    Please refer to [here](http://stackoverflow.com/questions/4057440/is-chromes-javascript-console-lazy-about-evaluating-arrays) about the behavior of "console.log" in Chrome – XuChu LIU Jun 13 '15 at 16:19
  • 2
    [Here's a jsfiddle](http://jsfiddle.net/0gdkrud8/) that demonstrates something similar. `QWeb.add_template()` is asynchronous so it takes a bit of time before `Qweb.templates` is populated. – robertklep Jun 13 '15 at 19:51

0 Answers0