forked from adamlaska/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponents.py
More file actions
37 lines (31 loc) · 1.02 KB
/
Copy pathcomponents.py
File metadata and controls
37 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.forms.widgets import flatatt
from .text import text_value
def render_icon(icon, title=''):
"""
Render a Bootstrap glyphicon icon
"""
attrs = {
'class': 'glyphicon glyphicon-{icon}'.format(icon=icon),
}
if title:
attrs['title'] = title
return '<span{attrs}></span>'.format(attrs=flatatt(attrs))
def render_alert(content, alert_type=None, dismissable=True):
"""
Render a Bootstrap alert
"""
button = ''
if not alert_type:
alert_type = 'info'
css_classes = ['alert', 'alert-' + text_value(alert_type)]
if dismissable:
css_classes.append('alert-dismissable')
button = '<button type="button" class="close" ' + \
'data-dismiss="alert" aria-hidden="true">×</button>'
return '<div class="{css_classes}">{button}{content}</div>'.format(
css_classes=' '.join(css_classes),
button=button,
content=text_value(content),
)