Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pyjsx/jsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ def __str__(self):
case _:
return self.convert_component(self.tag)

def __len__(self):
return len(str(self))

def __bytes__(self):
match self.tag:
case str():
return self.convert_builtin(self.tag).encode('utf-8')
case _:
return self.convert_component(self.tag).encode('utf-8')

def encode(self, encoding='utf-8', errors='strict'):
return str(self).encode(encoding, errors)

def convert_prop(self, key: str, value: Any) -> str:
if isinstance(value, bool):
return key if value else ""
Expand Down