@@ -15,33 +15,35 @@ normal Python. In most cases, the code will be more concise than standard HTML.
1515
1616
1717### Usage
18+
1819``` python
1920from simple_html.nodes import body, head, html, p
2021from simple_html.render import render
2122
2223node = html(
2324 head,
2425 body(
25- p.attrs(id = " hello" )(
26+ p.attrs(id = " hello" )(
2627 " Hello World!"
2728 )
2829 )
2930)
3031
31- render(node) # returns: <html><head></head><body><p id="hello">Hello World!</p></body></html>
32+ render(
33+ node) # returns: <html><head></head><body><p id="hello">Hello World!</p></body></html>
3234```
3335
3436
3537Strings are escaped by default, but you can pass in ` SafeString ` s to avoid escaping.
3638
3739``` python
38- from simple_html.nodes import br, p, SafeString
40+ from simple_html.nodes import br, p, safe_string
3941from simple_html.render import render
4042
4143node = p(
4244 " Escaped & stuff" ,
4345 br,
44- SafeString (" Not escaped & stuff" )
46+ safe_string (" Not escaped & stuff" )
4547)
4648
4749render(node) # returns: <p>Escaped & stuff<br/>Not escaped & stuff</p>
@@ -50,10 +52,10 @@ render(node) # returns: <p>Escaped & stuff<br/>Not escaped & stuff</p>
5052For convenience, many tags are provided, but you can create your own as well:
5153
5254``` python
53- from simple_html.nodes import TagBase
55+ from simple_html.nodes import Tag
5456from simple_html.render import render
5557
56- custom_elem = TagBase (" custom-elem" )
58+ custom_elem = Tag (" custom-elem" )
5759
5860render(
5961 custom_elem.attrs(id = " some-custom-elem-id" )(
0 commit comments