def render(self, name, value, attrs=None): return mark_safe( 'Generate photo <input type="checkbox" name="%s" %s /> at <input type="text" name="%s" /> second or use custom: %s' % \ (name + '_auto', value and ' ' or 'checked="true"', name + '_time', super(PhotoWidget, self).render(name, value, attrs),))
def html2text(s, ignore_tags=(), indent_width=4, page_width=80): ignore_tags = [t.lower() for t in ignore_tags] parser = HTML2Text(ignore_tags, indent_width, page_width) parser.feed(s) parser.close() parser.generate() return mark_safe(parser.result)
def render(self, context): """ Creates a renderable safe string for the tag. :Parameters: - `context`: current context information """ style = "text" if len(self.vlist) > 0: style = resolve_variable(self.vlist[0], context) result = "<pre>" + str(self.nodelist.render(context)) + "</pre>" return mark_safe(result)
def render(self, context): """ Creates a renderable safe string for the tag. :Parameters: - `context`: current context information """ style = "text" if len(self.vlist) > 0: style = resolve_variable(self.vlist[0], context) result = "<style>%s</style>" % HtmlFormatter().get_style_defs(".highlight") result += highlight( self.nodelist.render(context), get_lexer_by_name(style, encoding="UTF-8"), HtmlFormatter() ) return mark_safe(result)
def __init__(self, po, *args, **kwargs): self.po = po self.base_fields = {} prev = None for msg in po.nodes: if isinstance(msg, PoNodeMsg): name = msg.input_name() if name != "": if msg.is_multiline(): widget = admin_widgets.AdminTextareaWidget else: widget = admin_widgets.AdminTextInputWidget help = mark_safe("\n<br/>".join( prev.lines())) if msg else None self.base_fields[name] = forms.CharField( label=msg.input_label(), widget=widget, initial=msg.input_value(), required=False, help_text=help) prev = msg super(PoForm, self).__init__(*args, **kwargs)
def __init__(self, po, *args, **kwargs): self.po = po self.base_fields={} prev = None for msg in po.nodes: if isinstance(msg, PoNodeMsg): name = msg.input_name() if name!="": if msg.is_multiline(): widget = admin_widgets.AdminTextareaWidget else: widget = admin_widgets.AdminTextInputWidget help = mark_safe("\n<br/>".join(prev.lines())) if msg else None self.base_fields[name] = forms.CharField( label = msg.input_label(), widget = widget, initial = msg.input_value(), required = False, help_text = help ) prev = msg super(PoForm, self).__init__(*args, **kwargs)
def archive(release = True): '''Create a .tar.gz archive of the project directory. The :func:`djpcms.contrib.jdep.utils.project` must have been called already with the name of the project.''' import os import tarfile from django.template import loader, mark_safe utils.rmfiles(os.curdir, ext = 'pyc') filename = '%s.tar.gz' % env.project data = loader.render_to_string('jdep/server.txt', {'env':mark_safe('%s\n' % env), 'release': release}) if release: f = open('server.py','w') f.write(data) f.close() t = tarfile.open(filename, mode = 'w:gz') t.add(env.project) t.add('requirements.txt') t.add('__init__.py') t.add('server.py') t.close() local('rm server.py') else: env.server_script = data return filename
def render(self, context): return template.mark_safe(''.join(map(template.force_unicode, _render_nodelist_items(self,context))))
def render(self, context): return template.mark_safe(''.join( map(template.force_unicode, _render_nodelist_items(self, context))))
def human_msg(self): return mark_safe(u"%s %s %s:%s" % (self.user.username, self.get_action_display(), self.content_type.name, self.content_object))
def buildtag(name, content, **attrs): return mark_safe('<%s %s>%s</%s>' % (name, " ".join('%s="%s"' % i for i in attrs.items()), unicode(content), name))
def currency(value): #string = locale.currency(value, grouping=True) #return template.mark_safe(string) return template.mark_safe(money_format(value, curr="$", neg='(', trailneg=")"))
def short_currency(value): output = template.mark_safe(money_format(value, places=2, curr="$", neg='(', trailneg=")")) if output.endswith(".00"): return output[:-3] else: return output
def hyperlink(url, title, **attrs): return mark_safe('<a href="%s" %s>%s</a>' % (url, " ".join('%s="%s"' % i for i in attrs.items()), title))