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

Hyphenate attributes with certain prefixes #737

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

dyve
Copy link
Member

@dyve dyve commented Dec 16, 2024

No description provided.

@coveralls
Copy link

coveralls commented Dec 16, 2024

Pull Request Test Coverage Report for Build 12352593687

Details

  • 25 of 25 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 97.907%

Totals Coverage Status
Change from base Build 12348252146: 0.04%
Covered Lines: 1431
Relevant Lines: 1452

💛 - Coveralls

Co-authored-by: François Freitag <mail@franek.fr>
src/django_bootstrap5/html.py Outdated Show resolved Hide resolved
src/django_bootstrap5/html.py Outdated Show resolved Hide resolved
def render_tag(tag, attrs=None, content=None, close=True):
"""Render an HTML tag."""
prefixes = get_bootstrap_setting("hyphenate_attribute_prefixes") or []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not specifying should result in the default value being used.

Suggested change
prefixes = get_bootstrap_setting("hyphenate_attribute_prefixes") or []
prefixes = get_bootstrap_setting("hyphenate_attribute_prefixes") or ["data"]

if attrs:
for attr_name, attr_value in copy(attrs).items():
if has_prefix(attr_name, prefixes):
attrs[hyphenate(attr_name)] = attr_value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe error out or warn if the hyphenate key already exists?

dyve and others added 5 commits December 16, 2024 13:06
Co-authored-by: François Freitag <mail@franek.fr>
Co-authored-by: François Freitag <mail@franek.fr>
@francoisfreitag
Copy link
Contributor

Just as a reference, there’s a discussion about offering a method to pass attributes with hyphens on Django forums:
https://forum.djangoproject.com/t/proposal-allow-simple-tag-to-parse-attributes/36769/8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants