Skip to content

Commit

Permalink
Fix #380 Inherit templates in demo app from base template
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Mar 26, 2016
1 parent 2bef9df commit f4312fd
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
4 changes: 3 additions & 1 deletion demos/polls/aiohttpdemo_polls/templates/404.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<h1>Page Not Found</h1>
{% extends "base.html" %}

{% set title = "Page Not Found" %}
4 changes: 3 additions & 1 deletion demos/polls/aiohttpdemo_polls/templates/500.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<h1>Internal Server Error</h1>
{% extends "base.html" %}

{% set title = "Internal Server Error" %}
17 changes: 17 additions & 0 deletions demos/polls/aiohttpdemo_polls/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
{% block head %}
<link rel="stylesheet" type="text/css"
href="{{ url('static', filename='style.css') }}" />
<title>{{title}}</title>
{% endblock %}
</head>
<body>
<h1>{{title}}</h1>
<div>
{% block content %}
{% endblock %}
</div>
</body>
</html>
6 changes: 5 additions & 1 deletion demos/polls/aiohttpdemo_polls/templates/detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<h1>{{ question.question_text }}</h1>
{% extends "base.html" %}

{% set title = question.question_text %}

{% block content %}
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}

<form action="{{ url('vote', parts={'question_id': question.id}) }}" method="post">
Expand All @@ -9,3 +12,4 @@ <h1>{{ question.question_text }}</h1>
{% endfor %}
<input type="submit" value="Vote" />
</form>
{% endblock %}
7 changes: 5 additions & 2 deletions demos/polls/aiohttpdemo_polls/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<link rel="stylesheet" type="text/css"
href="{{ url('static', filename='style.css') }}" />
{% extends "base.html" %}

{% set title = "Main" %}

{% block content %}
{% if questions %}
<ul>
{% for question in questions %}
Expand All @@ -10,3 +12,4 @@
{% else %}
<p>No polls are available.</p>
{% endif %}
{% endblock %}
6 changes: 5 additions & 1 deletion demos/polls/aiohttpdemo_polls/templates/results.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<h1>{{ question.question }}</h1>
{% extends "base.html" %}

{% set title = question.question %}

{% block content %}
<ul>
{% for choice in choices %}
<li>{{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes }}</li>
{% endfor %}
</ul>

<a href="{{ url('poll', parts={'question_id': question.id}) }}">Vote again?</a>
{% endblock %}

0 comments on commit f4312fd

Please sign in to comment.