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

Allow setting template content directly on Nav? #46

Open
joshuadavidthomas opened this issue Feb 23, 2024 · 1 comment
Open

Allow setting template content directly on Nav? #46

joshuadavidthomas opened this issue Feb 23, 2024 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@joshuadavidthomas
Copy link
Member

joshuadavidthomas commented Feb 23, 2024

Curious about this, but as I create the demo with a bunch of examples, a thought occurred to me: should a nav's template be allowed to be set on the nav itself?

Example:

from django_simple_nav.nav import Nav
from django_simple_nav.nav import NavItem

class ExampleListNav(Nav):
    items = [
        NavItem(title="Tailwind CSS", url="/tailwind/"),
    ]
    template = """\
<ul>
  {% for item in items %}
    <li>
      <a href="{{ item.url }}"
         class="{% if item.active %}text-indigo-500 hover:text-indigo-300{% else %}hover:text-gray-400{% endif %}">
        {{ item.title }}
      </a>
    </li>
  {% endfor %}
</ul>"""
@joshuadavidthomas joshuadavidthomas added question Further information is requested enhancement New feature or request labels Feb 23, 2024
@joshuadavidthomas
Copy link
Member Author

As mentioned in #55, instead of adding a new attribute directly, we could move to using a get_template method that could then be overridden to provide a template string directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant