Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tag overrides’ default_html preventing real tag usage #199

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pattern_library/monkey_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from pattern_library.utils import is_pattern_library_context, render_pattern

logger = logging.getLogger(__name__)
UNSPECIFIED = object()


def override_tag(
Expand Down Expand Up @@ -78,7 +77,7 @@ def node_render(context):
# Render result instead of the tag, as a string.
# See https://github.com/torchbox/django-pattern-library/issues/166.
return str(result)
elif default_html is not UNSPECIFIED:
elif default_html is not None:
# Render provided default;
# if no stub data supplied.
return default_html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
SAND{% error_tag none %}WICH
SAND{% error_tag zero %}WICH

POTA{% default_html_tag page.url %}TO
POTA{% default_html_tag page.url %}TO
POTA{% default_html_tag page.child.url %}TO
POTA{% default_html_tag None %}TO

POTA{% default_html_tag_falsey empty_string %}TO1
POTA{% default_html_tag_falsey none %}TO2
POTA{% default_html_tag_falsey zero %}TO3
POTA{% default_html_tag_falsey zero %}TO3

Real tag usage: {% pageurl page %}
11 changes: 11 additions & 0 deletions tests/tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@


class TagsTestCase(SimpleTestCase):
def test_real_tag_usage(self):
response = self.client.get(
reverse(
"pattern_library:render_pattern",
kwargs={
"pattern_template_name": "patterns/atoms/tags_test_atom/tags_test_atom.html"
},
)
)
self.assertContains(response, "Real tag usage: /page/url")

def test_falsey_raw_values_for_tag_output(self):
response = self.client.get(
reverse(
Expand Down