diff --git a/docs/templates.html b/docs/templates.html index 748c956..1eb9d7a 100644 --- a/docs/templates.html +++ b/docs/templates.html @@ -115,6 +115,11 @@ Item.

able to iterate through them.

+

+ You also have access to the Config dictionary, which contains + the Venus configuration variables from your .ini file. +

+

If you lose your way and want to introspect all the variable in the context, there's the useful {% debug %} template tag. diff --git a/planet/shell/dj.py b/planet/shell/dj.py index 7724902..2ce316a 100644 --- a/planet/shell/dj.py +++ b/planet/shell/dj.py @@ -33,6 +33,7 @@ def run(script, doc, output_file=None, options={}): # datatype converters context = Context() context.update(tmpl.template_info(doc)) + context['Config'] = config.planet_options() t = get_template(script) if output_file: diff --git a/tests/data/filter/django/config.html.dj b/tests/data/filter/django/config.html.dj new file mode 100644 index 0000000..25fde8f --- /dev/null +++ b/tests/data/filter/django/config.html.dj @@ -0,0 +1 @@ +{{ Config.name }} diff --git a/tests/test_filter_django.py b/tests/test_filter_django.py index af4f46e..a7ca46a 100644 --- a/tests/test_filter_django.py +++ b/tests/test_filter_django.py @@ -26,6 +26,15 @@ class DjangoFilterTests(unittest.TestCase): os.path.realpath('tests/data/filter/django/title.html.dj'), input) self.assertEqual(results, "Atom-Powered Robots Run Amok\n") + def test_django_config_context(self): + config.load('tests/data/filter/django/test.ini') + feed = open('tests/data/filter/django/test.xml') + input = feed.read(); feed.close() + results = dj.run( + os.path.realpath('tests/data/filter/django/config.html.dj'), input) + self.assertEqual(results, "Django on Venus\n") + + try: from django.conf import settings except ImportError: