API
pyhtml.create_tag
Create a new PyHTML tag definition.
PyHTML already provides definitions for all standard HTML tags, so you don't need to use this unless you are using a JavaScript library that defines custom HTML elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the name of the tag. This is used during rendering, as
|
required |
base |
type[Tag]
|
the base class to use for the custom tag. The new tag will inherit from this base class. |
Tag
|
Returns:
Type | Description |
---|---|
type[Tag]
|
type[Tag]: a new tag definition. |
pyhtml.Tag
Base tag class
_get_default_attributes
Returns the default attributes for the tag given the specified attributes.
This is overridden by child classes to return a dictionary of default attributes that are applied to the class.
_get_tag_pre_content
Return "pre-content" for the tag.
This is used by the <html>
tag to add a <!DOCTYPE html>
before the
tag.
_render
Renders tag and its children to a list of strings where each string is a single line of output