class TextileWidget(forms.Textarea):
"""
A Textarea widget which appends basic Textile formating instructions:
http://www.textism.com/tools/textile/
"""
def render(self, name, value, attrs=None):
self.attrs = {'cols': '85', 'rows': '10'}
rendered = super(TextileWidget, self).render(name, value, attrs)
html = u'<div class="textile-examples"><p>*bold* → <strong>bold</strong> \
<br />_italic_ → <em>italic</em><br />#numeric list \
→ <ol>ordinal position</ol><br />*bullet list → \
<ul>ordinal position</ul><br/>"linktext":url → \
<a href="http://time.gov">creates link</a><br/><a \
href="http://hobix.com/textile/" target="_blank">[ view full textile \
reference ]</a></p></div>'
return rendered + mark_safe(html)
Comments