Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from abc import ABC, abstractmethod
- class HtmlBuilder:
- def __init__(self):
- self.html = ""
- def add_element(self, element):
- self.html += element.render()
- def get_html(self):
- return self.html
- class HtmlElement(ABC):
- @abstractmethod
- def render(self):
- pass
- class Div(HtmlElement):
- def render(self):
- return "<div></div>\n"
- class Label(HtmlElement):
- def render(self):
- return "<label>Label</label>\n"
- class Input(HtmlElement):
- def render(self):
- return "<input type='text'/>\n"
- class Select(HtmlElement):
- def render(self):
- return "<select><option>Option</option></select>\n"
- class Submit(HtmlElement):
- def render(self):
- return "<input type='submit'/>\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement