Skip to content

Commit

Permalink
replace underscores for dashed tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed Sep 17, 2023
1 parent 303a907 commit 1748058
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tagz"
version = "0.2.2"
version = "0.2.3"
description = "tagz is a html tags builder"
authors = ["Dmitry Orlov <me@mosquito.su>"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions tagz.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def __init__(self, defaults: Mapping[str, Mapping[str, Any]]):
self.__defaults: Mapping[str, Mapping[str, Any]] = MappingProxyType(defaults)

def __getitem__(self, tag_name: str) -> Type[TagInstance]:
tag_name = tag_name.lower().replace("_", "-")
return create_tag_class(tag_name, **self.__defaults.get(tag_name, {}))

def __getattr__(self, tag_name: str) -> Type[TagInstance]:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def test_tag_string_representation():
assert tag.to_string(pretty=True) == (
'<p>\n\tHello, World!\n\t<a href="/">\n\t\tgo to index\n\t</a>\n\t<i/>\n</p>\n'
)
assert html.my_custom_tag is html.my_custom_tag
assert str(html.my_custom_tag()) == "<my-custom-tag/>"
assert str(html.my_custom_tag("test")) == "<my-custom-tag>test</my-custom-tag>"


def test_html_generation(sample_html_page):
Expand Down

0 comments on commit 1748058

Please sign in to comment.