Eel: Jinja templates example not working correctly

Created on 16 Sep 2019  路  5Comments  路  Source: ChrisKnott/Eel

Hi,
I tried to run the example on both Windows 10 and Ubuntu 18.04, but it's not working correctly. I don't have any problem with all the other examples. This is the result:
jinja

I am simply running the script "hello.py".
Am I missing something?

I'm sure that Jinja is working correctly, because I did some tests, so the problem seems to be somewhere else.

Any help it's appreciated.
Thanks.

bug

Most helpful comment

After some investigations:

  1. Inside __init.py__ there is this line: _jinja_templates = kwargs.pop('templates', None). But, in the script of the example "hello.py" there is this line: eel.start('templates/hello.html', size=(300, 200), jinja_templates='templates'). It's a problem of name mismatch.
  2. Keeping hello.html as "start page", always generates a bad view. I've noticed that substituting page2.html inside the start() function in the file hello.py, the page is rendered correctly. It's also rendered correctly when copying the code of hello.html inside page2.html.
    Furthermore, everything works fine if I change the name of the template from hello.html to page3.html
    _static() function inside __init.py__ is not called when the file it's called hello.html

All 5 comments

After some investigations:

  1. Inside __init.py__ there is this line: _jinja_templates = kwargs.pop('templates', None). But, in the script of the example "hello.py" there is this line: eel.start('templates/hello.html', size=(300, 200), jinja_templates='templates'). It's a problem of name mismatch.
  2. Keeping hello.html as "start page", always generates a bad view. I've noticed that substituting page2.html inside the start() function in the file hello.py, the page is rendered correctly. It's also rendered correctly when copying the code of hello.html inside page2.html.
    Furthermore, everything works fine if I change the name of the template from hello.html to page3.html
    _static() function inside __init.py__ is not called when the file it's called hello.html

@ChrisKnott Fix it. @mattiaornaghi are right. It worked for me!

@mattiaornaghi please can you share what version of Eel you're using? I think you're using an older version of the library. 9c80660dd271ae196043558526db4ac030944965 fixed the kwarg name mismatch you're referring to. I suggest you update to v0.10.4

The current master branch of this repo is on v1.0.0-b1, although this isn't published to PyPi yet. I'll look at doing that, and setting up automated releases, in the next week or so.

FYI - I'm not able to reproduce this issue locally on any of the tagged versions of the code (from v0.10.0 to v0.10.4)

Based on no response, I'm going to close this issue for now. Please get back in touch if you think this is a mistake!

Was this page helpful?
0 / 5 - 0 ratings