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

8 lines
249 B
Python

from bs4 import BeautifulSoup
def format(soup: BeautifulSoup) -> None:
for element in soup.find_all(attrs={"dj-include": True}):
element.string = f'{{% include "{element.get("dj-include")}" %}}'
del element.attrs["dj-include"]