File tree Expand file tree Collapse file tree 5 files changed +66
-56
lines changed Expand file tree Collapse file tree 5 files changed +66
-56
lines changed Original file line number Diff line number Diff line change 249
249
"""
250
250
# Disable Flake8, since it really doesn't like our docstring above
251
251
# flake8: noqa
252
- from .__tag_base import Tag , Comment
252
+ from .__tag_base import Tag
253
253
254
254
from .__tags import input_ , object_
255
255
256
256
__all__ = [
257
- 'DangerousRawHtml' ,
258
257
'Tag' ,
258
+ 'DangerousRawHtml' ,
259
259
'Comment' ,
260
260
'input_' ,
261
261
'object_' ,
377
377
378
378
from .__tags import (
379
379
DangerousRawHtml ,
380
+ Comment ,
380
381
html ,
381
382
base ,
382
383
head ,
Original file line number Diff line number Diff line change @@ -116,57 +116,6 @@ def __repr__(self) -> str:
116
116
return self .render ()
117
117
118
118
119
- class Comment (Tag ):
120
- """
121
- An HTML comment.
122
-
123
- Renders as:
124
-
125
- ```html
126
- <!-- [comment text] -->
127
- ```
128
-
129
- Note that this does not render as a `<comment>` tag
130
- """
131
- def __init__ (self , text : str ) -> None :
132
- """
133
- An HTML comment.
134
-
135
- Renders as:
136
-
137
- ```html
138
- <!-- [comment text] -->
139
- ```
140
-
141
- Note that this does not render as a `<comment>` tag
142
- """
143
- self .comment_data = text
144
- super ().__init__ ()
145
-
146
- def __call__ (self ):
147
- raise TypeError ('Comment tags are not callable' )
148
-
149
- def _get_tag_name (self ) -> str :
150
- # Ignore coverage since this is only implemented to satisfy inheritance
151
- # and is never used since we override _render
152
- return '!--' # pragma: no cover
153
-
154
- def _render (self ) -> list [str ]:
155
- """
156
- Override of render, to render comments
157
- """
158
-
159
- return [
160
- '<!--' ,
161
- * util .increase_indent (
162
- util .escape_string (self .comment_data ).splitlines (),
163
- # FIXME: Yucky magic number
164
- 2 ,
165
- ),
166
- '-->'
167
- ]
168
-
169
-
170
119
class SelfClosingTag (Tag ):
171
120
"""
172
121
Self-closing tags don't contain child elements
Original file line number Diff line number Diff line change 7
7
from .renames import input_ , object_
8
8
from .input import input
9
9
from .dangerous_raw_html import DangerousRawHtml
10
+ from .comment import Comment
10
11
11
12
# Copy this into pyhtml/__tags/__init__.py
12
13
__all__ = [
13
14
# This one is generated by hand
14
15
'input' ,
15
16
# These are extra features of PyHTML enhanced
16
17
'DangerousRawHtml' ,
18
+ 'Comment' ,
17
19
# These two are renamed
18
20
'input_' ,
19
21
'object_' ,
Original file line number Diff line number Diff line change
1
+ """
2
+ # PyHTML Enhanced / Tags / Comment
3
+
4
+ Definition for the comment tag.
5
+ """
6
+ from ..__tag_base import Tag
7
+ from .. import __util as util
8
+
9
+
10
+ class Comment (Tag ):
11
+ """
12
+ An HTML comment.
13
+
14
+ Renders as:
15
+
16
+ ```html
17
+ <!-- [comment text] -->
18
+ ```
19
+
20
+ Note that this does not render as a `<comment>` tag
21
+ """
22
+ def __init__ (self , text : str ) -> None :
23
+ """
24
+ An HTML comment.
25
+
26
+ Renders as:
27
+
28
+ ```html
29
+ <!-- [comment text] -->
30
+ ```
31
+
32
+ Note that this does not render as a `<comment>` tag
33
+ """
34
+ self .comment_data = text
35
+ super ().__init__ ()
36
+
37
+ def __call__ (self ):
38
+ raise TypeError ('Comment tags are not callable' )
39
+
40
+ def _get_tag_name (self ) -> str :
41
+ # Ignore coverage since this is only implemented to satisfy inheritance
42
+ # and is never used since we override _render
43
+ return '!--' # pragma: no cover
44
+
45
+ def _render (self ) -> list [str ]:
46
+ """
47
+ Override of render, to render comments
48
+ """
49
+
50
+ return [
51
+ '<!--' ,
52
+ * util .increase_indent (
53
+ util .escape_string (self .comment_data ).splitlines (),
54
+ # FIXME: Yucky magic number
55
+ 2 ,
56
+ ),
57
+ '-->'
58
+ ]
Original file line number Diff line number Diff line change 7
7
"""
8
8
import pytest
9
9
import pyhtml
10
- from pyhtml import Tag , Comment
10
+ from pyhtml import Tag , Comment , DangerousRawHtml
11
11
12
12
13
13
all_tags = [
20
20
and type (getattr (pyhtml , i )) == type
21
21
# That are a kind of Tag
22
22
and issubclass (getattr (pyhtml , i ), Tag )
23
- # And aren't a comment (since comments require named args)
24
- and not issubclass (getattr (pyhtml , i ), Comment )
23
+ # And aren't a PyHTML feature (since comments require named args)
24
+ and not issubclass (getattr (pyhtml , i ), ( Comment , DangerousRawHtml ) )
25
25
)
26
26
]
27
27
You can’t perform that action at this time.
0 commit comments