Skip to content

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

  1. Python-Friendly Tags
  2. Zenaura resolves conflicts with Python keywords by renaming certain HTML tags.
  3. Example: Use input_ for the <input> tag to avoid conflicts.

  4. Special Attributes

  5. Some HTML attributes are adjusted for Python compatibility:

    • classclass_
    • forfor_
    • namename_
    • typetype_
  6. Attribute Value Normalization

  7. Boolean values are converted to valid HTML:

    • True"true"
    • False"false"
  8. Dynamic Processing

  9. Attributes and tag names are processed internally for proper rendering:
    def process_attributes(attrs: List[Attribute]) -> str:
        # Converts Python-friendly attributes to valid HTML
    

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:

<div class="form-group">
  <input type="text" name="username" class="form-control">
</div>

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. 🚀