Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: includes/toc.tmpl

Issue 5158802752012288: Issue 2306 - Add toc macro to web.adblockplus.org (Closed)
Patch Set: Made spacing more consistent. Created April 13, 2015, 11:19 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: includes/toc.tmpl
diff --git a/includes/toc.tmpl b/includes/toc.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..a8fee2a70e815ac0a5de68eba19ebf0674e54088
--- /dev/null
+++ b/includes/toc.tmpl
@@ -0,0 +1,33 @@
+{#
+ # This file is part of the Adblock Plus website,
+ # Copyright (C) 2006-2015 Eyeo GmbH
+ #
+ # Adblock Plus is free software: you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License version 3 as
+ # published by the Free Software Foundation.
+ #
+ # Adblock Plus is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ #}
+
+{% macro toc(page, title_tag) %}
Wladimir Palant 2015/04/13 12:00:36 Should be title_tag=None the way I see it, this pa
kzar 2015/04/13 12:49:13 Done.
+ {% set page_content = get_page_content(page) %}
+ {% set toclist = page_content["body"]|toclist %}
+
+ {% if title_tag %}
+ <{{ title_tag }}>{{ page_content["title"] }}</{{ title_tag }}>
+ {% endif %}
+ <ul>
+ {% for item in toclist %}
+ <li>
+ <a href="{{ page }}#{{ item.anchor }}">{{ item.title }}</a>
Wladimir Palant 2015/04/13 12:00:36 This is a relative link, it won't work correctly i
kzar 2015/04/13 12:49:13 Ouch, Done.
+ {% if item.subitems %}{{ toc(item.subitems) }}{% endif %}
+ </li>
+ {% endfor %}
+ </ul>
+{% endmacro %}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld