Eel: Jinja folder structure

Created on 5 Mar 2019  路  4Comments  路  Source: ChrisKnott/Eel

With the new addition of Jinja (bless you <3), the folder structure doesn't really work in a logical way.

When I initialize eel without Jinja...

eel.init("web")
eel.start("templates/recordPicker.html", size=(800, 500))

I can access css through <link rel="stylesheet" type='text/css' href="/css/recordPicker.css" /> with the directory starting in my web folder.

However, when I initialize eel WITH Jinja...

eel.init("web")
eel.start("templates/recordPicker.html", size=(800, 500), templates='templates')

I can no longer access css through <link rel="stylesheet" type='text/css' href="/css/recordPicker.css" />. When I try this, a Jinja error will come up that says jinja2.exceptions.TemplateNotFound: er.css, where er.css is the file name I am looking for MINUS some leading characters equal to the number of characters in my templates folder + 1 (Why?).

I would prefer to always search for files in my main web folder and not have the directory changed when using templates, which I think causes confusion. Is there a way to use Jinja without specifying another folder, or to use Jinja but have access to the base web directory?

Most helpful comment

This is the same problem as in your other issue and should be solved by upgrading to eel v0.10.2. There is a bug in v0.10.1 that tries to render all files through Jinja, even if they're not inside the jinja templates directory.

All 4 comments

@ClayMDMI To be completely honest I am not totally familiar with how Jinja2 works. I believe the contributor who wrote this feature did it in such a way to limit impact on non-Jinja usage.

It might take me a while to figure out what is going on here unless someone else wants to chip in @sanders41 @samuelhwilliams

This is the same problem as in your other issue and should be solved by upgrading to eel v0.10.2. There is a bug in v0.10.1 that tries to render all files through Jinja, even if they're not inside the jinja templates directory.

It seems what happened is @ChrisKnott pushed code to master without testing it properly

There is still a problem with Jinja, it's not rendering the files under the defined templates directory: eel.start('templates/index.html', size=(350, 500), jinja_templates='templates')
web/templates contains files: index.html and layout.html
index.html contains{% extends 'layout.html' %}
index.html gets rendered outputting: {% extends 'layout.html' %} withou jinja ever touching these directives.

Was this page helpful?
0 / 5 - 0 ratings