Created
March 16, 2018 01:04
-
-
Save jordanhudgens/63b280d6ac3799b0969d5daac0ccc49a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Html: | |
def __init__(self, content): | |
self.content = content | |
def render(self): | |
raise NotImplementedError("Subclass must implement render method") | |
class Heading(Html): | |
def render(self): | |
return f'<h1>{self.content}</h1>' | |
class Div(Html): | |
def render(self): | |
return f'<div>{self.content}</div>' | |
tags = [Div('Some content'), Heading('My Amazing Heading'), Div('Another div')] | |
for tag in tags: | |
print(str(tag) + ': ' + tag.render()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment