summaryrefslogtreecommitdiff
path: root/docs/_templates/layout.html
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2010-05-08 20:31:59 +0000
committerLuke Plant <L.Plant.98@cantab.net>2010-05-08 20:31:59 +0000
commitd5ed0302289db2a8b64ebd29ca1081dab364d1ee (patch)
tree6fad10e4739f28124af2f6283fc980391c0ae693 /docs/_templates/layout.html
parente8e87e09b90dca37c1da064e0472e7e2cc43ad88 (diff)
[1.1.X] Added hyperlinks for builtin template tags and filters to code samples in docs.
Implemented in javascript because doing it 'properly' is pretty much impossible with Sphinx and Pygments. Refs #12249 Backport of [13135] from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@13137 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/_templates/layout.html')
-rw-r--r--docs/_templates/layout.html37
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html
index e0e69520ad..70e029c3ac 100644
--- a/docs/_templates/layout.html
+++ b/docs/_templates/layout.html
@@ -16,6 +16,43 @@
{%- endif %}
{%- endmacro %}
+{% block extrahead %}
+{{ super() }}
+<script type="text/javascript" src="{{ pathto('templatebuiltins.js', 1) }}"></script>
+<script type="text/javascript">
+(function($) {
+ if (!django_template_builtins) {
+ // templatebuiltins.js missing, do nothing.
+ return;
+ }
+ $(document).ready(function() {
+ // Hyperlink Django template tags and filters
+ var base = "{{ pathto('ref/templates/builtins') }}";
+ if (base == "#") {
+ // Special case for builtins.html itself
+ base = "";
+ }
+ // Tags are keywords, class '.k'
+ $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
+ var tagname = $(elem).text();
+ if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
+ var fragment = tagname.replace(/_/, '-');
+ $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
+ }
+ });
+ // Filters are functions, class '.nf'
+ $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
+ var filtername = $(elem).text();
+ if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
+ var fragment = filtername.replace(/_/, '-');
+ $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
+ }
+ });
+ });
+})(jQuery);
+</script>
+{% endblock %}
+
{% block document %}
<div id="custom-doc" class="{% block bodyclass %}{{ 'yui-t6' if pagename != 'index' else '' }}{% endblock %}">
<div id="hd">