Sorry for the complete newbie question, and apologies in advance if this isn't the right place to post this, but I'm trying to revamp my portfolio site and have been pulling my hair out for 3 days trying to get Jinja 2 templates to work.
I originally designed my site 3 years ago in Python 2.5 and Django but am trying to migrate to Jinja2 (per the tutorial on the Python site). I have gotten to the point where I can get the app to display the parent base.html template, but it won't display anything from the index.html child template. I've posted all my code below, so if someone could please tell me where I'm going wrong, it just might save my sanity.
Thanks in advance
#app.yaml code
application: dev-bds2shields
version: 2
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: webapp2
version: latest
- name: jinja2
version: latest
handlers:
- url: /.*
script: index.app
#index.py code
# -*- coding: utf-8 -*-
import cgi
import os
import webapp2
import jinja2
from jinja2 import Environment, PackageLoader,FileSystemLoader, Template
env = Environment(loader = PackageLoader('index', 'templates'))
template = env.get_template('base.html')
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.out.write(template.render())
app = webapp2.WSGIApplication(routes=[
( r'/', MainPage ),
], debug=True)
#base.html code (parent)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="style.css" />
<title>{% block title %}{% endblock %} - My Webpage</title>
{% block html_head %}{% endblock %}
</head>
<body>
<div id="content">
{% block content %}{% endblock %}
</div>
<div id="footer">
{% block footer %}
© Copyright 2006 by <a href="http://mydomain.tld">myself</a>.
{% endblock %}
</div>
</body>
#index.html code (child)
{% extends "base.html %}
{% block title %}Index{% endblock %}
{% block html_head %}
<style type="text/css">
.important {
color: #336699;
}
</style>
Placeholder
{% endblock %}
{% block content %}
<h1>Index</h1>
<p class="important">
Welcome on my awsome homepage.
</p>
{% endblock %}