Permalink
Browse files

* added help view

* added default help template
* improved bbhelp tag (with template)
  • Loading branch information...
1 parent e44716c commit b1b4cfde83713902426e52fc1d4a85892fccb953 ojii committed Dec 28, 2009
Showing with 37 additions and 2 deletions.
  1. +19 −0 templates/bbcode/bbhelp.html
  2. +4 −0 templates/bbcode/bbtag.html
  3. +4 −2 templatetags/bbcode.py
  4. +10 −0 views.py
@@ -0,0 +1,19 @@
+{% load bbcode %}
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
+ <head>
+ <title>django-bbcode - Help</title>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
+ <meta name="description" content="django-bbcode help" />
+ <meta name="keywords" content="django-bbcode, bbcode, django, help" />
+ <meta name="author" content="Jonas Obrist" />
+ <meta http-equiv="pragma" content="no-cache" />
+ <meta http-equiv="cache-control" content="no-cache" />
+ </head>
+ <body>
+ <h1>django-bbcode Help</h1>
+ {% bbhelp using "bbcode/bbtag.html" %}
+ </body>
+</html>
@@ -0,0 +1,4 @@
+<div class="tag">
+ <h1>{{ tag.name }}</h1>
+ {{ tag.docstring|safe }}
+</div>
View
@@ -105,8 +105,10 @@ def render(self, context):
realtplfile = self.tplfile.resolve(context)
except template.VariableDoesNotExist:
return ''
- data = {'tags': bbmodule.get_help(*self.tags)}
- return render_to_string(self.tplfile, data)
+ rendered_tags = []
+ for tag in self.tags:
+ rendered_tags.append(render_to_string(self.tplfile, {'tag': tag}))
+ return '\n'.join(rendered_tags)
View
@@ -0,0 +1,10 @@
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+def help(request, template_name='bbcode/bbhelp.html', extra_context=None):
+ if extra_context is None:
+ extra_context = {}
+ context = RequestContext(request)
+ for key, value in extra_context.items():
+ context[key] = callable(value) and value() or value
+ return render_to_response(template_name, context_instance=context)

0 comments on commit b1b4cfd

Please sign in to comment.