express.ui.TagList
self, *args) express.ui.TagList(
Create an HTML tag list (i.e., a fragment of HTML)
Parameters
*args : TagChild = ()
-
The tag children to add to the list.
Examples
>>> from htmltools import TagList, div
>>> TagList("hello", div(id="foo", class_="bar"))
hello<div id="foo" class="bar"></div>
Methods
Name | Description |
---|---|
append | Append tag children to the end of the list. |
extend | Extend the children by appending an iterable of children. |
get_dependencies | Get any dependencies needed to render the HTML. |
get_html_string | Return the HTML string for this tag list. |
insert | Insert tag children before a given index. |
render | Get string representation as well as its HTML dependencies. |
save_html | Save to a HTML file. |
show | Preview as a complete HTML document. |
tagify | Convert any tagifiable children to Tag/TagList objects. |
append
*args) express.ui.TagList.append(item,
Append tag children to the end of the list.
extend
express.ui.TagList.extend(other)
Extend the children by appending an iterable of children.
get_dependencies
=True) express.ui.TagList.get_dependencies(dedup
Get any dependencies needed to render the HTML.
Parameters
dedup : bool = True
-
Whether to deduplicate the dependencies.
get_html_string
express.ui.TagList.get_html_string(=0
indent='\n'
eol*
=True
add_ws=True
_escape_strings )
Return the HTML string for this tag list.
Parameters
indent : int = 0
-
Number of spaces to indent each line of the HTML.
eol : str = ''
-
End-of-line character(s).
add_ws : bool = True
-
Whether to add whitespace between the opening tag and the first child. If either this is True, or the child’s add_ws attribute is True, then whitespace will be added; if they are both False, then no whitespace will be added.
insert
express.ui.TagList.insert(i, item)
Insert tag children before a given index.
render
express.ui.TagList.render()
Get string representation as well as its HTML dependencies.
save_html
file, *, libdir='lib', include_version=True) express.ui.TagList.save_html(
Save to a HTML file.
Parameters
Returns
: str
-
The path to the generated HTML file.
show
='auto') express.ui.TagList.show(renderer
Preview as a complete HTML document.
Parameters
renderer : Literal[‘auto’, ‘ipython’, ‘browser’] = 'auto'
-
The renderer to use.
tagify
express.ui.TagList.tagify()
Convert any tagifiable children to Tag/TagList objects.