Builder
Builder
A builder class for constructing HTML tags.
This class provides a fluent interface for creating HTML tags with attributes, children, and styles. It simplifies the process of building complex HTML structures.
Attributes:
Name | Type | Description |
---|---|---|
node |
Node
|
The root node of the tag being built. |
Source code in zenaura/client/tags/builder.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
__init__(name='div')
Initializes a Builder object with the given tag name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the tag. Defaults to "div". |
'div'
|
build()
with_attribute(key, value)
Adds an attribute to the tag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The key of the attribute. |
required |
value |
any
|
The value of the attribute. |
required |
Returns:
Name | Type | Description |
---|---|---|
Builder |
Builder
|
The Builder object. |
Source code in zenaura/client/tags/builder.py
with_attribute_if(key, value, condition)
adds attribute if condition is true args: key (str): The key of the attribute. value: The value of the attribute. condition (bool): The condition for adding the attribute.
Source code in zenaura/client/tags/builder.py
with_attributes(**kwargs)
Adds attributes to the tag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Key-value pairs of attributes. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Builder |
Builder
|
The Builder object. |
Source code in zenaura/client/tags/builder.py
with_child(child)
with_child_if(child, condition)
adds child if condition is true args: child (Node): The child node to be added. condition (bool): The condition for adding the child.
Source code in zenaura/client/tags/builder.py
with_children(*children)
Adds child nodes to the tag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*children |
List of child nodes. |
()
|
Returns:
Name | Type | Description |
---|---|---|
Builder |
Builder
|
The Builder object. |
Source code in zenaura/client/tags/builder.py
with_class(class_name)
Adds a single class name to the element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name |
str
|
The class name to be added. |
required |
Returns:
Name | Type | Description |
---|---|---|
Builder |
Builder
|
The Builder object. |
Source code in zenaura/client/tags/builder.py
with_class_if(class_name, condition)
Adds a class name to the element if the condition is True. If the condition is False, the class is not added.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name |
str
|
The class name to be added. |
required |
condition |
bool
|
The condition for adding the class. |
required |
Source code in zenaura/client/tags/builder.py
with_classes(*class_names)
Adds multiple class names to the element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*class_names |
str
|
Variable number of class names. |
()
|
Returns:
Name | Type | Description |
---|---|---|
Builder |
Builder
|
The Builder object. |
Source code in zenaura/client/tags/builder.py
with_styles(styles)
Adds styles to the tag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
styles |
dict
|
Dictionary of styles. |
required |
Returns:
Name | Type | Description |
---|---|---|
Builder |
Builder
|
The Builder object. |