bare.py 726 B

123456789101112131415161718192021222324252627282930
  1. """A bare component."""
  2. from __future__ import annotations
  3. from typing import Any
  4. from pynecone.components.component import Component
  5. from pynecone.components.tags import Tag
  6. from pynecone.components.tags.tagless import Tagless
  7. from pynecone.var import Var
  8. class Bare(Component):
  9. """A component with no tag."""
  10. contents: Var[str]
  11. @classmethod
  12. def create(cls, contents: Any) -> Component:
  13. """Create a Bare component, with no tag.
  14. Args:
  15. contents: The contents of the component.
  16. Returns:
  17. The component.
  18. """
  19. return cls(contents=str(contents)) # type: ignore
  20. def _render(self) -> Tag:
  21. return Tagless(contents=str(self.contents))