我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用django.template.defaultfilters.escape()。
def style_element(text): low_text = text.strip().lower() if low_text in YES_KEYWORDS: return YES_IMG if low_text in NO_KEYWORDS: return NO_IMG if plus_two_re.search(low_text): return YES_IMG * 2 if minus_two_re.search(low_text): return NO_IMG * 2 if plus_three_re.search(low_text): return YES_IMG * 3 if minus_three_re.search(low_text): return NO_IMG * 3 text = escape(text) found = False for positive in YES_KEYWORDS: if text.startswith(positive): text = '%s %s' % (YES_IMG, text[len(positive):]) found = True break if not found: for negative in NO_KEYWORDS: if text.startswith(negative): text = '%s %s' % (NO_IMG, text[len(negative):]) break return text
def html_escape(value): from django.template.defaultfilters import escape return escape(value)
def get_meta_keywords(self): meta_tag = "" if self.meta_keywords: meta_tag = """<meta name="keywords" content="%s" />\n""" % escape(self.meta_keywords) return mark_safe(meta_tag)
def get_meta_description(self): meta_tag = "" if self.meta_description: meta_tag = """<meta name="description" content="%s" />\n""" % escape(self.meta_description) return mark_safe(meta_tag)
def get_meta_author(self): meta_tag = "" if self.meta_author: meta_tag = """<meta name="author" content="%s" />\n""" % escape(self.meta_author) return mark_safe(meta_tag)
def get_meta_copyright(self): meta_tag = "" if self.meta_copyright: meta_tag = """<meta name="copyright" content="%s" />\n""" % escape(self.meta_copyright) return mark_safe(meta_tag)
def get_meta_keywords(self): meta_tag = u"" if self.meta_keywords: meta_tag = u"""<meta name="keywords" content="%s" />\n""" % escape(self.meta_keywords) return mark_safe(meta_tag)
def get_meta_description(self): meta_tag = u"" if self.meta_description: meta_tag = u"""<meta name="description" content="%s" />\n""" % escape(self.meta_description) return mark_safe(meta_tag)
def get_meta_author(self): meta_tag = u"" if self.meta_author: meta_tag = u"""<meta name="author" content="%s" />\n""" % escape(self.meta_author) return mark_safe(meta_tag)
def item_content(self, notification): return {"type": "html"}, linebreaks(escape(notification.message))