def save(self, *args, **kwargs): # We store it in any case to also check the parser for possible exceptions and to use it for __unicode__ (content, parser) = utils.markup_parser(self.body, self.markup) self.body_html = content self.body_scripts = '\n'.join(parser.get_scripts()) self.body_stylesheets = '\n'.join(parser.get_stylesheets()) if not utils.get_markup_object(self.markup).is_dynamic: self.dynamic = False return super(MarkupField, self).save(*args, **kwargs)
def render(self, context): if self.dynamic: (content, parser) = utils.markup_parser(self.body, self.markup, context, context.get('placeholder')) context['markup_scripts'] = context.get('markup_scripts', []) + parser.get_scripts() context['markup_stylesheets'] = context.get('markup_stylesheets', []) + parser.get_stylesheets() return mark_safe(content) else: context['markup_scripts'] = context.get('markup_scripts', []) + self.body_scripts.split('\n') context['markup_stylesheets'] = context.get('markup_stylesheets', []) + self.body_stylesheets.split('\n') return mark_safe(self.body_html)
def render(self, context): if self.dynamic: (content, parser) = utils.markup_parser(self.body, self.markup, context, context.get('placeholder')) context['markup_scripts'] = context.get('markup_scripts', []) + parser.get_scripts() context['markup_stylesheets'] = context.get( 'markup_stylesheets', []) + parser.get_stylesheets() return mark_safe(content) else: context['markup_scripts'] = context.get( 'markup_scripts', []) + self.body_scripts.split('\n') context['markup_stylesheets'] = context.get( 'markup_stylesheets', []) + self.body_stylesheets.split('\n') return mark_safe(self.body_html)
def render(self, context): if self.dynamic: return mark_safe(utils.markup_parser(self.body, self.markup, context, context.get('placeholder'))) else: return mark_safe(self.body_html)
def save(self, *args, **kwargs): # We store it in any case to also check the parser for possible exceptions and to use it for __unicode__ self.body_html = utils.markup_parser(self.body, self.markup) if not utils.get_markup_object(self.markup).is_dynamic: self.dynamic = False return super(MarkupField, self).save(*args, **kwargs)