Skip to content
Snippets Groups Projects
Commit 759a70ef authored by Alice Heaton's avatar Alice Heaton :speech_balloon:
Browse files

Allow the basic text widget to display html

parent ab0d0c48
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
{{ title }} {{ title }}
</div> </div>
<div class='panel-body'> <div class='panel-body'>
{{ text }} {% if html %}
{{ text|safe }}
{% else %}
{{ text }}
{% endif %}
</div> </div>
</div> </div>
...@@ -36,15 +36,19 @@ class BasicTextWidget(object): ...@@ -36,15 +36,19 @@ class BasicTextWidget(object):
Settings: Settings:
title: The widget title title: The widget title
text: The widget text text: The widget text
html: If true, the content contains html.
If false, the content should be escaped.
""" """
template_name = 'dashboard/basic-text-widget.html' template_name = 'dashboard/basic-text-widget.html'
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
title = kwargs.get('title', '(no title') title = kwargs.get('title', '(no title')
text = kwargs.get('text', '(no text)') text = kwargs.get('text', '(no text)')
html = kwargs.get('html', False)
return { return {
'title': title, 'title': title,
'text': text 'text': text,
'html': html
} }
register_widget('basic-text-widget', BasicTextWidget()) register_widget('basic-text-widget', BasicTextWidget())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment