move render method to base class
@@ -113,23 +113,34 @@ class ButtonFormMixin(EntangledModelFormMixin):
class BootstrapButtonMixin(IconPluginMixin):
require_parent = True
- parent_classes = ('BootstrapColumnPlugin', 'SimpleWrapperPlugin',)
+ parent_classes = ['BootstrapColumnPlugin', 'SimpleWrapperPlugin']
render_template = 'cascade/bootstrap4/button.html'
allow_children = False
default_css_class = 'btn'
default_css_attributes = ['button_type', 'button_size', 'button_options', 'stretched_link']
ring_plugin = 'ButtonMixin'
- form = ButtonFormMixin
require_icon = False
class Media:
js = ['cascade/js/admin/buttonmixin.js']
+ def render(self, context, instance, placeholder):
+ self.super(BootstrapButtonMixin, self).render(context, instance, placeholder)
+ if 'icon_font_class' in context:
+ mini_template = '{0}<i class="{1} {2}" aria-hidden="true"></i>{3}'
+ icon_align = instance.glossary.get('icon_align')
+ if icon_align == 'icon-left':
+ context['icon_left'] = format_html(mini_template, '', context['icon_font_class'], 'cascade-icon-left', ' ')
+ elif icon_align == 'icon-right':
+ context['icon_right'] = format_html(mini_template, ' ', context['icon_font_class'], 'cascade-icon-right', '')
+ return context
+
class BootstrapButtonPlugin(BootstrapButtonMixin, LinkPluginBase):
module = 'Bootstrap'
name = _("Button")
model_mixins = (LinkElementMixin,)
+ form = ButtonFormMixin
ring_plugin = 'ButtonPlugin'
require_icon = False
DEFAULT_BUTTON_ATTRIBUTES = {'role': 'button'}
@@ -162,15 +173,4 @@ class BootstrapButtonPlugin(BootstrapButtonMixin, LinkPluginBase):
attributes.update(cls.DEFAULT_BUTTON_ATTRIBUTES)
return attributes
- def render(self, context, instance, placeholder):
- self.super(BootstrapButtonPlugin, self).render(context, instance, placeholder)
- if 'icon_font_class' in context:
- mini_template = '{0}<i class="{1} {2}" aria-hidden="true"></i>{3}'
- icon_align = instance.glossary.get('icon_align')
- if icon_align == 'icon-left':
- context['icon_left'] = format_html(mini_template, '', context['icon_font_class'], 'cascade-icon-left', ' ')
- elif icon_align == 'icon-right':
- context['icon_right'] = format_html(mini_template, ' ', context['icon_font_class'], 'cascade-icon-right', '')
- return context
-
plugin_pool.register_plugin(BootstrapButtonPlugin)
