Created
March 22, 2014 09:49
-
-
Save oprypin/1dfeb7cfbb66a7e26bab to your computer and use it in GitHub Desktop.
How Flask+Jinja2 templating should be done generally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
{% block head %} | |
<title>{% block title %}Awesome website{% endblock %}</title> | |
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}"/> | |
{% endblock head %} | |
</head> | |
<body> | |
<header> | |
<div id="logo"> | |
<a href="/" title="Go to home page"><img src="{{ url_for('static', filename='logo.png') }}" alt="Logo"/></a> | |
</div> | |
</header> | |
<main role="main"> | |
{% block content %} | |
{% endblock content %} | |
</main> | |
<footer> | |
{% block footer %} | |
Copyright blah blah | |
{% endblock footer %} | |
</footer> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block title %}User {{ user.name }} - {{ super() }}{% endblock %} | |
{% block content %} | |
<div> | |
{{ user.name }} | |
{% if user is sameas current_user() %} | |
<form action="{{ url_for('logout') }}" method="POST"> | |
<input type="submit" value="Log out"/> | |
</form> | |
{% endif %} | |
</div> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment