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: Addressed Wladimir's comments. Created April 13, 2015, 12:47 p.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..ea04142e635a4d0bc0ae241a6dd58a7de9be2976
--- /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=None) %}
+ {% 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>
+ {{ (page + '#' + item.anchor)|linkify }}{{ item.title }}</a>
+ {% 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