as_tag¶
- bootlace.util.as_tag(item: Taggable | dom_tag | str | Iterable[Taggable | dom_tag]) dom_tag[source]¶
Convert an item to a dominate tag.
bootlaceusesdominateto render HTML. To do this, objects implement theTaggableprotocol, providing a__tag__dunder method. This method will also accept regulardominatetags, strings, and iterables ofTaggableobjects. It will try to always return adominatetag.To render taggable objects in a template, use
render(), a convenience function that will convert the object to adominatetag and then render it to aMarkupobject for use in a template.Handling notes¶
When a string is passed in, it will be wrapped with
dominate.util.textto render a literal string as a tag. When an iterable of taggable items is passed, it is returned as adominate.util.container, which will render the tags in sequence.Unknown types are displayed using their string representation (by calling
stron them), along with a comment in the rendered HTML and aBootlacewarning emitted.Arguments¶
- param item:
The item to convert to
dominatetags.- returns:
A
dominatetag.