Describe the problem
I'm trying to use the {% include %} syntax, but I'm getting TemplateNotFound error.
I took out my layouts from my eleventy project but since eel is not a static site generator and doesn't supply any prefix path like in Eleventy, Jekyll or any other SSGs for the includes and layouts, I pointed out my include like this {% include "../includes/appbar/base.html" %}
here's my folder structure
and below is the traceback when I tried to use {% include %}
Traceback (most recent call last):
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\bottle.py", line 876, in _handle
return route.call(**args)
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\bottle.py", line 1756, in wrapper
rv = callback(*a, **ka)
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\eel\__init__.py", line 221, in _static
response = btl.HTTPResponse(template.render())
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\environment.py", line 1301, in render
self.environment.handle_exception()
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "D:\Projects\Python\Playground\eel\test-project-1\source\layouts\index.html", line 1, in top-level template code
{% extends "base.html" %}
File "D:\Projects\Python\Playground\eel\test-project-1\source\layouts\base.html", line 15, in top-level template code
{% include "../includes/appbar/base.html" %}
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\loaders.py", line 195, in get_source
pieces = split_template_path(template)
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\loaders.py", line 36, in split_template_path
raise TemplateNotFound(template)
Traceback (most recent call last):
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\bottle.py", line 876, in _handle
return route.call(**args)
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\bottle.py", line 1756, in wrapper
rv = callback(*a, **ka)
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\eel\__init__.py", line 221, in _static
response = btl.HTTPResponse(template.render())
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\environment.py", line 1301, in render
self.environment.handle_exception()
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "D:\Projects\Python\Playground\eel\test-project-1\source\layouts\index.html", line 1, in top-level template code
{% extends "base.html" %}
File "D:\Projects\Python\Playground\eel\test-project-1\source\layouts\base.html", line 15, in top-level template code
{% include "includes/appbar/base.html" %}
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\loaders.py", line 218, in get_source
raise TemplateNotFound(template)
Traceback (most recent call last):
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\bottle.py", line 876, in _handle
return route.call(**args)
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\bottle.py", line 1756, in wrapper
rv = callback(*a, **ka)
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\eel\__init__.py", line 221, in _static
response = btl.HTTPResponse(template.render())
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\environment.py", line 1301, in render
self.environment.handle_exception()
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "D:\Projects\Python\Playground\eel\test-project-1\source\layouts\index.html", line 1, in top-level template code
{% extends "base.html" %}
File "D:\Projects\Python\Playground\eel\test-project-1\source\layouts\base.html", line 15, in top-level template code
{% include "../includes/appbar/base.html" %}
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\loaders.py", line 195, in get_source
pieces = split_template_path(template)
File "D:\Projects\Python\Playground\eel\test-project-1\venv\lib\site-packages\jinja2\loaders.py", line 36, in split_template_path
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: ../includes/appbar/base.html
Code snippet(s)
Here is some code that can be easily used to reproduce the problem or understand what I need help with.
[x] I know that if I don't provide sample code that allows someone to quickly step into my shoes, I may not get the help I want or my issue may be closed.
# File: "./main.py"
import eel
import platform
import sys
def main():
source_path = 'source'
main_page = 'layouts/index.html'
eel_kwargs = dict(
mode = 'chrome',
host = 'localhost',
port = 8080,
size = (850, 480)
)
try:
eel.init(source_path)
eel.start(main_page, jinja_templates='layouts', **eel_kwargs)
except EnvironmentError:
if sys.platform in ['win32', 'win64'] and int(platform.release()) >= 10:
eel.start(main_page, jinja_templates='layouts', **eel_kwargs)
else:
raise
if __name__ == '__main__':
main()
Describe the problem I'm trying to use the {% include %} syntax, but I'm getting TemplateNotFound error.
I took out my layouts from my eleventy project but since eel is not a static site generator and doesn't supply any prefix path like in Eleventy, Jekyll or any other SSGs for the includes and layouts, I pointed out my include like this
{% include "../includes/appbar/base.html" %}
here's my folder structure
and below is the traceback when I tried to use {% include %}
Code snippet(s) Here is some code that can be easily used to reproduce the problem or understand what I need help with.
Desktop (please complete the following information):
Smartphone (please complete the following information):