Sigma
Sigma

Reputation: 800

How to include other HTML files as module in tornado

I have a template file called main.html and I want to add my navbar in nav.html to my main.html. How can I do that in tornado? I looked in tornado documents where they recommended to use

{% module Template("module-entry.html", show_comments=True) %}

However when I tried to add my module as

 {% module Template("nav.html") %}

I got FileNotFoundException

FileNotFoundError: [Errno 2] No such file or directory: '/home/sigma/PycharmProjects/tornadoProj/__/views/nav.html'

I don't understand how __ gets in my path? Help?

Upvotes: 0

Views: 344

Answers (1)

mjzhou
mjzhou

Reputation: 46

I'm not use module,you can use block in main.html you can like this

<html>
<body>
    <header>
        {% block header %}{% end %}
    </header>
    <content>
        {% block body %}{% end %}
    </content>
    <footer>
        {% block footer %}{% end %}
    </footer>
</body>
</html>

In nav.html:

{% block header %}
    <ul><li>...</li><li>...</li><li>...</li></ul>
{% end %}

Upvotes: 1

Related Questions