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

Arbitrary HTML in Bootstrap Tab #1011

Open
geoffrey-eisenbarth opened this issue Apr 1, 2020 · 3 comments
Open

Arbitrary HTML in Bootstrap Tab #1011

geoffrey-eisenbarth opened this issue Apr 1, 2020 · 3 comments

Comments

@geoffrey-eisenbarth
Copy link

  • Package version: 1.8.1
  • Django version: 3.0.2
  • Python version: 3.7.3
  • Template pack: bootstrap3

Description:

Currently it's not possible to include, e.g., FontAwesome icons in a bootstrap3 tab. I was able to get it working by replacing {{ link.name|capfirst }} with {{ link.name|safe }} in templates/bootstrap3/layout/tab-link.html and then

self.helper.layout = Layout(
  TabHolder(
    Tab(
      '<i class="fa fa-align-left"></i> Align Left',
      Row(<tab_content>),
      css_id='align-left',
    ),
  ),
)

I don't know if |safe becomes a security issue or if people don't think this functionality is needed, but I like to put icons in my tabs so I figured I'd suggest it to the community. Currently, with the |capfirst tag the tab will show the HTML as text instead of rendering the icon. Thoughts?

@smithdc1
Copy link
Member

smithdc1 commented Apr 6, 2020

Hi @geoffrey-eisenbarth

I think |safe is fine as you are in control of it (presumably you don't want to load malicious html in here yourself 👍 ). |safe is used a fair amount in crispy template packs.

As for incorporating this into the template packs, I'm trying to work out if the change would cause a regression issue? Presumably most people have just a tab name, so may cause some tab names to be lower case...

In conclusion if this is a wide enough use case then I say let's have it. Are you in a position to raise a PR (bs4 pack as well please) and we can get it reviewed more widely?

Thanks!

@geoffrey-eisenbarth
Copy link
Author

Good point about the regression issue. Perhaps I'm mistaken, but the examples in the docs imply that the first argument in Tab should be formatted how you want it to look (e.g., "First Tab"), so I don't think that many users are aware that the text is being run through |capfirst. Thoughts?

I don't mind submitting a PR, I should have some time tomorrow in the afternoon.

@smithdc1
Copy link
Member

smithdc1 commented Apr 13, 2020

Hey, no rush, if you could submit a pr whenever you have time that would be great :+1

Take care.

David

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

No branches or pull requests

2 participants