# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.forms.widgets import flatatt
from django.utils.safestring import mark_safe
from bootstrap3.utils import render_tag

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 render_tag('span', attrs=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">&times;</button>'
    button_placeholder = '__BUTTON__'
    return mark_safe(render_tag(
        'div',
        attrs={'class': ' '.join(css_classes)},
        content=button_placeholder + text_value(content),
    ).replace(button_placeholder, button))

@@ -243,16 +243,16 @@
 on, 
-title=''
+**kwargs
 ):%0A 
@@ -312,35 +312,19 @@
     
-attrs = %7B%0A        'class': 
+classes = %5B
 'gly
@@ -365,16 +365,146 @@
 on=icon)
+%5D%0A    if kwargs.get('add_class'):%0A        classes.append(kwargs.get('add_class'))%0A    attrs = %7B%0A        'class': ' '.join(classes)
 ,%0A    %7D%0A
@@ -510,21 +510,35 @@
 %0A    if 
+kwargs.get('
 title
+')
 :%0A      
@@ -556,21 +556,36 @@
 tle'%5D = 
+kwargs.get('
 title
+')%0A
 %0A    ret

Allow passing extra classes into render_icon, for example to set text-success