Files
test/html_to_django/formatters/attr_formatter.py
T
2024-05-05 14:31:34 +02:00

9 lines
268 B
Python

from bs4 import BeautifulSoup
def format(soup: BeautifulSoup) -> None:
for element in soup.find_all(attrs={"dj-attr": True}):
tag, value = element.get("dj-attr").split(";")
element[tag] = f"{{{{ {value} }}}}"
del element.attrs["dj-attr"]