def render(self, name, value, attrs=None): html = super(RedactorEditor, self).render(name, value, attrs) final_attrs = self.build_attrs(attrs) id_ = final_attrs.get('id') json_options = json_dumps(self.options) html += self.init_js % (id_, json_options) return mark_safe(html)
def render(self, name, value, attrs=None, renderer=None): """ Must parse self.options with json_dumps on self.render. Because at some point Django calls RedactorEditor.__init__ before loading the urls, and it will break. """ attrs['data-redactor-options'] = json_dumps(self.options) html = super(RedactorEditor, self).render(name, value, attrs) return mark_safe(html)
def render(self, name, value, attrs=None): attrs["data-redactor-options"] = json_dumps(self.options) html = super(RedactorEditor, self).render(name, value, attrs) eclass = re.search('class="([^\\"]*)"', html) attrs["class"] = "%s %s" % (eclass.group(1), "redactor-box") html = super(RedactorEditor, self).render(name, value, attrs) return mark_safe(html)
def render(self, name, value, attrs=None, **kwargs): """ Must parse self.options with json_dumps on self.render. Because at some point Django calls RedactorEditor.__init__ before loading the urls, and it will break. """ attrs['data-redactor-options'] = json_dumps(self.options) html = super(RedactorEditor, self).render(name, value, attrs, **kwargs) return mark_safe(html)
def render(self, name, value, attrs=None): if 'class' not in attrs.keys(): attrs['class'] = '' attrs['class'] += ' redactor-box' attrs['data-redactor-options'] = json_dumps(self.options) html = super(RedactorEditor, self).render(name, value, attrs) return mark_safe(html)
def __init__(self, *args, **kwargs): self.upload_to = kwargs.pop('upload_to', '') self.custom_options = kwargs.pop('redactor_options', {}) self.allow_file_upload = kwargs.pop('allow_file_upload', True) self.allow_image_upload = kwargs.pop('allow_image_upload', True) default_attrs = { 'class': 'redactor-box', 'data-redactor-options': json_dumps(self.options) } if 'attrs' in kwargs: default_attrs.update(kwargs['attrs']) kwargs['attrs'] = default_attrs super(RedactorEditor, self).__init__(*args, **kwargs)