Introduction to Zenaura Tags
Zenaura simplifies UI development by providing Pythonic representations of HTML tags. These tags allow you to define and manipulate DOM elements directly in Python, ensuring consistency and maintainability in your web applications.
Key Features of Zenaura Tags
- Python-Friendly Tags
- Zenaura resolves conflicts with Python keywords by renaming certain HTML tags.
-
Example: Use
input_
for the<input>
tag to avoid conflicts. -
Special Attributes
-
Some HTML attributes are adjusted for Python compatibility:
class
→class_
for
→for_
name
→name_
type
→type_
-
Attribute Value Normalization
-
Boolean values are converted to valid HTML:
True
→"true"
False
→"false"
-
Dynamic Processing
- Attributes and tag names are processed internally for proper rendering:
Example: Using Tags and Attributes
Python Code:
from zenaura.ui import div, input_
div(
input_(type_="text", name_="username", class_="form-control"),
class_="form-group"
)
Rendered HTML:
Special Tags and Attributes
Special Tags
Zenaura resolves Python keyword conflicts by renaming certain tags:
- input_
→ <input>
Special Attributes
Zenaura adjusts certain attributes for compatibility:
| Python Attribute | HTML Attribute |
|-------------------|----------------|
| class_
| class
|
| for_
| for
|
| name_
| name
|
| type_
| type
|
Boolean Values
Boolean values are normalized:
| Python Value | HTML Value |
|--------------|------------|
| True
| "true"
|
| False
| "false"
|
Best Practices
- Use
class_
,for_
, and other special attributes to avoid Python conflicts. - Refactor repeated structures into reusable components for clarity and maintainability.
- Leverage Python logic to dynamically adjust attributes and values.
By adopting Zenaura’s Pythonic tags, attributes, and special handling mechanisms, you can create dynamic, readable, and maintainable web UIs efficiently. 🚀