diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2010-05-08 14:31:20 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2010-05-08 14:31:20 +0000 |
| commit | b09581394e7dd7629e71c775d1cc7160b0c26184 (patch) | |
| tree | dfb721ed9dc5570a2345b90f1c51798d7cb7ed08 /docs/_templates/layout.html | |
| parent | cfc05d8d688f17cdd9827b9fdbfc8770b291c109 (diff) | |
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
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13135 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/_templates/layout.html')
| -rw-r--r-- | docs/_templates/layout.html | 37 |
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"> |
