@@ -20,7 +20,7 @@ def actual_decorator(func):
20
20
@functools .wraps (func )
21
21
def wrapped (* args , ** kwargs ):
22
22
attrs = get_attrs_str (decorator_kwargs )
23
- return f"<b{ attrs } >" + func (* args , ** kwargs ) + " </b>"
23
+ return f"<b{ attrs } >{ func (* args , ** kwargs )} </b>"
24
24
25
25
return wrapped
26
26
@@ -32,7 +32,7 @@ def actual_decorator(func):
32
32
@functools .wraps (func )
33
33
def wrapped (* args , ** kwargs ):
34
34
attrs = get_attrs_str (decorator_kwargs )
35
- return f"<i{ attrs } >" + func (* args , ** kwargs ) + " </i>"
35
+ return f"<i{ attrs } >{ func (* args , ** kwargs )} </i>"
36
36
37
37
return wrapped
38
38
@@ -58,12 +58,37 @@ def deco(f):
58
58
59
59
def multi (func ):
60
60
return composed (
61
+ custom_tag (
62
+ name = "a" ,
63
+ href = "https://example.com" ,
64
+ title = "Hint!" ,
65
+ ),
61
66
makebold (foo = "1" ),
62
67
makeitalic (bar = "2" ),
63
68
upper ,
64
69
)(func )
65
70
66
71
72
+ def custom_tag (
73
+ name : str ,
74
+ ** arguments ,
75
+ ):
76
+ def actual_decorator (func ):
77
+ @functools .wraps (func )
78
+ def wrapped (* args , ** kwargs ):
79
+ attrs = get_attrs_str (arguments )
80
+ return f"<{ name } { attrs } >{ func (* args , ** kwargs )} </{ name } >"
81
+
82
+ return wrapped
83
+
84
+ return actual_decorator
85
+
86
+
87
+ @custom_tag (
88
+ name = "a" ,
89
+ href = "https://example.com" ,
90
+ title = "Hint!" ,
91
+ )
67
92
@makebold (foo = "1" )
68
93
@makeitalic (bar = "2" )
69
94
@upper
@@ -77,7 +102,7 @@ def hello_2(text):
77
102
78
103
79
104
print (hello ("Hello World!" ))
80
- # <b foo="1"><i bar="2">HELLO WORLD!</i></b>
105
+ # <a href="https://example.com" title="Hint!">< b foo="1"><i bar="2">HELLO WORLD!</i></b></a >
81
106
82
107
print (hello_2 ("Hello World!" ))
83
- # <b foo="1"><i bar="2">HELLO WORLD!</i></b>
108
+ # <a href="https://example.com" title="Hint!">< b foo="1"><i bar="2">HELLO WORLD!</i></b></a >
0 commit comments