本文整理匯總了Python中webhelpers2.html.HTML.optimize_attrs方法的典型用法代碼示例。如果您正苦於以下問題:Python HTML.optimize_attrs方法的具體用法?Python HTML.optimize_attrs怎麽用?Python HTML.optimize_attrs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類webhelpers2.html.HTML
的用法示例。
在下文中一共展示了HTML.optimize_attrs方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_boolean_true
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_boolean_true(self):
a = {"defer": True, "disabled": "1", "multiple": 1,
"readonly": "readonly"}
b = {"defer": "defer", "disabled": "disabled", "multiple": "multiple",
"readonly": "readonly"}
HTML.optimize_attrs(a)
assert a == b
示例2: test_boolean_true_with_additional_boolean_attr
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_boolean_true_with_additional_boolean_attr(self):
a = {"defer": True, "data-foo": True}
b = {"defer": "defer", "data-foo": "data-foo"}
HTML.optimize_attrs(a, set(["data-foo"]))
assert a == b
示例3: test_boolean_false
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_boolean_false(self):
a = {"defer": False, "multiple": 0, "readonly": ""}
b = {}
HTML.optimize_attrs(a)
assert a == b
示例4: test_data
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_data(self):
a = {"data_foo": "bar"}
b = {"data-foo": "bar"}
HTML.optimize_attrs(a)
assert a == b
示例5: test_multiple_optimizations
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_multiple_optimizations(self):
a = {"class_": ["A", "B"], "style": ["C", "D"], "bad": None}
b = {"class": "A B", "style": "C; D", }
HTML.optimize_attrs(a)
assert a == b
示例6: test_delete_none
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_delete_none(self):
a = {"title": "Foo", "wicked": None}
b = {"title": "Foo"}
HTML.optimize_attrs(a)
assert a == b
示例7: test_conditional_list3
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_conditional_list3(self):
a = {"class": [("first", False), ("even", False)] }
b = {}
HTML.optimize_attrs(a)
assert a == b
示例8: test_shouldnt_change_attrs
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_shouldnt_change_attrs(self):
a = {"style": "aa", "class": "bb", "data-foo": "bar"}
b = a
HTML.optimize_attrs(a)
assert a == b
示例9: test_conditional_list2
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_conditional_list2(self):
a = {"class": [("first", True), ("even", True)] }
b = {"class": "first even"}
HTML.optimize_attrs(a)
assert a == b
示例10: test_tuple
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_tuple(self):
a = {"class": ("aa", "bb")}
b = {"class": "aa bb"}
HTML.optimize_attrs(a)
assert a == b
示例11: test_list_empty
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_list_empty(self):
a = {"class": []}
b = {}
HTML.optimize_attrs(a)
assert a == b
示例12: test_list2
# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import optimize_attrs [as 別名]
def test_list2(self):
a = {"class_": ["foo", "bar"], "class": "baz"}
b = {"class": "foo bar"}
HTML.optimize_attrs(a)
assert a == b