Tags
Note
Tags, or Air Tag, are explained in the [concepts document about tags][air-tags].
In the spirit of helping our users, every Air Tag has copious documentation—enough that sometimes it breaks the documentation build process. Therefore, Air Tag that directly correspond to their HTML equivalents can be found in smaller, easier-to-compile pages.
- [HTML Air Tags A-D][tags-a-d]
- [HTML Air Tags E-M][tags-e-m]
- [HTML Air Tags N-S][tags-n-s]
- [HTML Air Tags T-Z][tags-t-z]
What remains on this page are core Air Tag that either have great utility (Raw and Children come to mind), or are base classes for other tags.
Tag
Tag(*children, **kwargs)
Base tag for all other tags.
Sets four attributes, name, module, children, and attrs. These are important for Starlette view responses, as nested objects get auto-serialized to JSON and need to be rebuilt. With the values of these attributes, the object reconstruction can occur.
kwargs: Keyword arguments transformed into tag attributes.
Source code in src/air/tags/models/base.py
21 22 23 24 25 26 27 28 29 |
|
Raw
Raw(*args, **kwargs)
Bases: Tag
Renders raw HTML content without escaping.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args
|
Any
|
A single string containing raw text to render |
()
|
Raises:
Type | Description |
---|---|
TypeError
|
If non-string content is provided |
ValueError
|
If multiple arguments are provided |
Example:
# Produces '<strong>Bold</strong> text'
Raw('<strong>Bold</strong> text')
# Use with other tags
Div(
P("Safe content"),
Raw('<hr class="divider">'),
P("More safe content")
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Any
|
Should be exactly one string argument |
()
|
**kwargs
|
str | int | float | bool
|
Ignored (for consistency with Tag interface) |
{}
|
Source code in src/air/tags/models/special.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
render
render()
Render the string without escaping.
Source code in src/air/tags/models/special.py
57 58 59 |
|
Children
Children(*children, **kwargs)
Bases: Tag
Source code in src/air/tags/models/base.py
21 22 23 24 25 26 27 28 29 |
|
SafeStr
Bases: str
A string subclass that doesn't trigger html.escape() when called by Tag.render()
Example
sample = SafeStr('Hello, world')