ui.TagList
ui.TagList(self, *args)
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
ui.TagList.append(item, *args)
Append tag children to the end of the list.
extend
ui.TagList.extend(other)
Extend the children by appending an iterable of children.
get_dependencies
ui.TagList.get_dependencies(dedup=True)
Get any dependencies needed to render the HTML.
Parameters
dedup: bool = True
-
Whether to deduplicate the dependencies.
get_html_string
ui.TagList.get_html_string(indent=0, eol='\n', *, add_ws=True, _escape_strings=True)
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
ui.TagList.insert(i, item)
Insert tag children before a given index.
render
ui.TagList.render()
Get string representation as well as its HTML dependencies.
save_html
ui.TagList.save_html(file, *, libdir='lib', include_version=True)
Save to a HTML file.
Parameters
Returns
Type | Description |
---|---|
str | The path to the generated HTML file. |
show
ui.TagList.show(renderer='auto')
Preview as a complete HTML document.
Parameters
renderer: Literal[‘auto’, ‘ipython’, ‘browser’] = ‘auto’
-
The renderer to use.
tagify
ui.TagList.tagify()
Convert any tagifiable children to Tag/TagList objects.