Frage

I have a small GAE app that's working fine. I use it to serve a few static files as well like (About page, Privacy and contact page). I put the "about.html" in a /static folder along with the /css, /img and /js. In "app.yaml" I declared the handler:

- url: /static
  static_dir: static

It all works fine. Now I've abstracted the common contents (navigations, etc) into "_base.html" like this:

<html>
<head><title> Page title here</title>
<!--Some header files here -->
</head>

<div id="content">
  {% block bodycontent %}

  {% endblock bodycontent %}    
</div>
</body> 
</html>

The child file looks like this:

{% extends "_base.html" %}
{% block title %} About {% endblock %}
{% block bodycontent %} 

<p>Some contents here...</p>

{% endblock bodycontent %}

Now, problem when it displays, the "_base.html" does not render. In fact the whole jinja code just displays. But when I wrote an handler for "about.html" it renders the base html correctly.

Question is, why do I have to create instances b4 I can display static files like About, Privacy pages just because I want to use template inheritance? Am I doing something wrong?

War es hilfreich?

Lösung

Templates are not static files, by definition. If you want a completely static HTML file, you can of course have one without any handler code. But templates require rendering, which means they need a handler to do it.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top