Skip to content

Commit

Permalink
replace attr with kwargs on p()
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavr2003 committed Jul 19, 2021
1 parent 1c2dc74 commit b6f4a49
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/sierra/tTags.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,15 @@ def css(self, **kwargs):
open("style.css", 'a+').write("\n}")


def p(text, attr=None):
if attr != None:
with open("index.html", 'a+') as f:
f.write(f'''\n<p {attr}>
{text}
</p>''')
else:
with open("index.html", 'a+') as f:
f.write(f'''\n<p>
{text}
</p>''')
def p(text, **kwargs):

if not kwargs:
open('index.html', 'a+').write(f"\n<p>\n{text}\n</p>")

else:
all_attr = "<p ", *(f' {key.replace("__", "").replace("_", "-")}="{value}"' for key, value in kwargs.items()), ">"

with open('index.html', 'a+') as f:
f.write(f"\n{join_attr(all_attr)}")
f.write(f"\n{text}\n</p>")

0 comments on commit b6f4a49

Please sign in to comment.