Commits

David Chambers committed 68cd0f5

Renamed base template `_base.dhtml`, and created a new `base.dhtml` which simply extends `_base.dhtml`. Added `nav` and `footer` blocks. These changes facilitate customization of the base template without unnecessary duplication.

  • Participants
  • Parent commits e27ed4a

Comments (0)

Files changed (2)

File templates/_base.dhtml

+<!DOCTYPE html>{% load mango_extras %}
+<html>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+	<title>{% block title %}{{ SITE_TITLE }}{% endblock %}</title>
+	<link rel="alternate" type="application/atom+xml" href="{% url mango.feeds.atom %}" />{% for stylesheet in stylesheets %}
+	<link rel="stylesheet" type="text/css" href="{{ stylesheet.href }}" media="{{ stylesheet.media }}" />{% endfor %}
+	<!--[if IE]>
+	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+	<![endif]-->
+</head>
+<body>
+	<div id="wrap">
+		<header id="header">{% url mango.views.index as path %}{% ifequal request.path path %}
+			<h1 id="title">{{ SITE_TITLE }}</h1>{% else %}
+			<a id="title" href="{{ path }}">{{ SITE_TITLE }}</a>{% endifequal %}
+			<nav>
+				<ul>{% block nav %}
+					<li>{% url mango.views.archives as path %}{% ifequal request.path path %}Archives{% else %}<a href="{{ path }}">Archives</a>{% endifequal %}</li>{% if TAGS_PAGE %}
+					<li>{% url mango.views.tags as path %}{% ifequal request.path path %}Tags{% else %}<a href="{{ path }}">Tags</a>{% endifequal %}</li>{% endif %}{% if CONTACT_FORM %}
+					<li>{% url mango.views.contact as path %}{% ifequal request.path path %}Contact{% else %}<a href="{{ path }}">Contact</a>{% endifequal %}</li>{% endif %}{% endblock %}
+				</ul>
+			</nav>
+			<form action="{% url mango.views.search %}">
+				<div>
+					<label for="query">Search</label>
+					<input type="search" id="query" name="query"{% if terms %} value="{{ terms|to_query_string }}"{% endif %} />
+				</div>
+				<div>
+					<input type="submit" value="Search" />
+				</div>
+			</form>
+		</header>
+		<div id="main">{% block content %}{% endblock %}
+		</div>
+	</div>
+	<footer id="footer">{% block footer %}
+		<p>Powered by <a href="http://mango.io/">Mango</a></p>{% endblock %}
+	</footer>{% for script in scripts %}
+	<script src="{{ script }}"></script>{% endfor %}
+	<script type="text/javascript">
+		(function () {
+
+			// thanks Douglas Crockford for this elegant function
+			function walkTheDOM(node, func) {
+				func(node);
+				node = node.firstChild;
+				while (node) {
+					walkTheDOM(node, func);
+					node = node.nextSibling;
+				}
+			}
+
+			var nodeNames = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
+			nodeNames.contains = function (nodeName) {
+				var i = this.length;
+				while (i--) {
+					if (this[i] === nodeName) return true;
+				}
+				return false;
+			};
+
+			walkTheDOM(document.getElementById('main'), function (node) {
+				if (node.id && nodeNames.contains(node.nodeName)) {
+					var a = document.createElement('a');
+					a.href = '#' + node.id;
+					a.className = 'permalink';
+					a.appendChild(document.createTextNode('\u00B6')); // pilcrow
+					node.appendChild(a);
+				}
+			});
+
+		}());
+	</script>{% if GOOGLE_ANALYTICS_ID %}
+	<script type="text/javascript">
+		var _gaq = _gaq || [];
+		_gaq.push(['_setAccount', '{{ GOOGLE_ANALYTICS_ID }}']);
+		_gaq.push(['_trackPageview']);
+
+		(function () {
+			var ga = document.createElement('script');
+			ga.type = 'text/javascript';
+			ga.async = true;
+			ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+			(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
+		}());
+	</script>{% endif %}
+	<!-- Generated by Mango -->
+</body>
+</html>

File templates/base.dhtml

-<!DOCTYPE html>{% load mango_extras %}
-<html>
-<head>
-	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-	<title>{% block title %}{{ SITE_TITLE }}{% endblock %}</title>
-	<link rel="alternate" type="application/atom+xml" href="{% url mango.feeds.atom %}" />{% for stylesheet in stylesheets %}
-	<link rel="stylesheet" type="text/css" href="{{ stylesheet.href }}" media="{{ stylesheet.media }}" />{% endfor %}
-	<!--[if IE]>
-	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
-	<![endif]-->
-</head>
-<body>
-	<div id="wrap">
-		<header id="header">{% url mango.views.index as path %}{% ifequal request.path path %}
-			<h1 id="title">{{ SITE_TITLE }}</h1>{% else %}
-			<a id="title" href="{{ path }}">{{ SITE_TITLE }}</a>{% endifequal %}
-			<nav>
-				<ul>
-					<li>{% url mango.views.archives as path %}{% ifequal request.path path %}Archives{% else %}<a href="{{ path }}">Archives</a>{% endifequal %}</li>{% if TAGS_PAGE %}
-					<li>{% url mango.views.tags as path %}{% ifequal request.path path %}Tags{% else %}<a href="{{ path }}">Tags</a>{% endifequal %}</li>{% endif %}{% if CONTACT_FORM %}
-					<li>{% url mango.views.contact as path %}{% ifequal request.path path %}Contact{% else %}<a href="{{ path }}">Contact</a>{% endifequal %}</li>{% endif %}
-				</ul>
-			</nav>
-			<form action="{% url mango.views.search %}">
-				<div>
-					<label for="query">Search</label>
-					<input type="search" id="query" name="query"{% if terms %} value="{{ terms|to_query_string }}"{% endif %} />
-				</div>
-				<div>
-					<input type="submit" value="Search" />
-				</div>
-			</form>
-		</header>
-		<div id="main">{% block content %}{% endblock %}
-		</div>
-	</div>
-	<footer id="footer">
-		<p>Powered by <a href="http://mango.io/">Mango</a></p>
-	</footer>{% for script in scripts %}
-	<script src="{{ script }}"></script>{% endfor %}
-	<script type="text/javascript">
-		(function () {
-
-			// thanks Douglas Crockford for this elegant function
-			function walkTheDOM(node, func) {
-				func(node);
-				node = node.firstChild;
-				while (node) {
-					walkTheDOM(node, func);
-					node = node.nextSibling;
-				}
-			}
-
-			var nodeNames = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
-			nodeNames.contains = function (nodeName) {
-				var i = this.length;
-				while (i--) {
-					if (this[i] === nodeName) return true;
-				}
-				return false;
-			};
-
-			walkTheDOM(document.getElementById('main'), function (node) {
-				if (node.id && nodeNames.contains(node.nodeName)) {
-					var a = document.createElement('a');
-					a.href = '#' + node.id;
-					a.className = 'permalink';
-					a.appendChild(document.createTextNode('\u00B6')); // pilcrow
-					node.appendChild(a);
-				}
-			});
-
-		}());
-	</script>{% if GOOGLE_ANALYTICS_ID %}
-	<script type="text/javascript">
-		var _gaq = _gaq || [];
-		_gaq.push(['_setAccount', '{{ GOOGLE_ANALYTICS_ID }}']);
-		_gaq.push(['_trackPageview']);
-
-		(function () {
-			var ga = document.createElement('script');
-			ga.type = 'text/javascript';
-			ga.async = true;
-			ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-			(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
-		}());
-	</script>{% endif %}
-	<!-- Generated by Mango -->
-</body>
-</html>
+{% extends '_base.dhtml' %}