summaryrefslogtreecommitdiff
path: root/sphinx/jinja2glue.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/jinja2glue.py')
-rw-r--r--sphinx/jinja2glue.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py
index f9b97e3d8..629bce30f 100644
--- a/sphinx/jinja2glue.py
+++ b/sphinx/jinja2glue.py
@@ -41,6 +41,15 @@ def accesskey(context, key):
return 'accesskey="%s"' % key
return ''
+class idgen(object):
+ def __init__(self):
+ self.id = 0
+ def current(self):
+ return self.id
+ def next(self):
+ self.id += 1
+ return self.id
+
class SphinxFileSystemLoader(FileSystemLoader):
"""
@@ -109,6 +118,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
self.environment.filters['toint'] = _toint
self.environment.globals['debug'] = contextfunction(pformat)
self.environment.globals['accesskey'] = contextfunction(accesskey)
+ self.environment.globals['idgen'] = idgen
if use_i18n:
self.environment.install_gettext_translations(
builder.app.translator)