本文整理匯總了Python中webhelpers2.html.HTML.cdata方法的典型用法代碼示例。如果您正苦於以下問題:Python HTML.cdata方法的具體用法?Python HTML.cdata怎麽用?Python HTML.cdata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類webhelpers2.html.HTML
的用法示例。
在下文中一共展示了HTML.cdata方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: js_obfuscate
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import cdata [as 別名]
def js_obfuscate(content):
"""Obfuscate data in a Javascript tag.
Example::
>>> js_obfuscate("<input type='hidden' name='check' value='valid' />")
literal(u'<script type="text/javascript">\\n//<![CDATA[\\neval(unescape(\\'%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%69%6e%70%75%74%20%74%79%70%65%3d%27%68%69%64%64%65%6e%27%20%6e%61%6d%65%3d%27%63%68%65%63%6b%27%20%76%61%6c%75%65%3d%27%76%61%6c%69%64%27%20%2f%3e%27%29%3b\\'))\\n//]]>\\n</script>')
"""
doc_write = "document.write('%s');" % content
obfuscated = ''.join(['%%%x' % ord(x) for x in doc_write])
complete = "eval(unescape('%s'))" % obfuscated
cdata = HTML.cdata("\n", complete, "\n//")
return HTML.script("\n//", cdata, "\n", type="text/javascript")
示例2: test_cdata2
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import cdata [as 別名]
def test_cdata2(self):
a = HTML.cdata(u"<p>")
b = literal("<![CDATA[<p>]]>")
self.check(a, b)
示例3: test_cdata
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import cdata [as 別名]
def test_cdata(self):
a = HTML.cdata("Foo")
b = literal("<![CDATA[Foo]]>")
self.check(a, b)