Added, tested and documented the new Config variable available in the Django templates/filters: makes it easy to access .ini configuration items from one's templates
This commit is contained in:
parent
a590d13fe8
commit
fb29d39501
@ -115,6 +115,11 @@ Item.</p>
|
||||
able to iterate through them.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You also have access to the <code>Config</code> dictionary, which contains
|
||||
the Venus configuration variables from your <code>.ini</code> file.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you lose your way and want to introspect all the variable in the
|
||||
context, there's the useful <code>{% debug %}</code> template tag.
|
||||
|
@ -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:
|
||||
|
1
tests/data/filter/django/config.html.dj
Normal file
1
tests/data/filter/django/config.html.dj
Normal file
@ -0,0 +1 @@
|
||||
{{ Config.name }}
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user