prymitive / bootstrap-breadcrumbs

Django template tags for easy breadcrumbs using twitter bootstrap css classes or custom template
django-bootstrap-breadcrumbs.readthedocs.org
MIT License
92 stars 47 forks source link

kwargs are not supported? #15

Closed mark0978 closed 10 years ago

mark0978 commented 10 years ago

{% breadcrumb customer 'customer-details' cust_id=customer.id %}

TemplateSyntaxError at /customers/edit-contact/2/3/ 'breadcrumb' received unexpected keyword argument 'cust_id'

Since you were using reverse, I would have expected it to allow for kwargs as well as positional args.

prymitive commented 10 years ago

I'll check that later today and push a fix if needed. Thanks

prymitive commented 10 years ago

Can you test latest code from github? If it works I'll push new version to pypi. Thanks

mark0978 commented 10 years ago

I'll test it tonight.

mark0978 commented 10 years ago

This no longer throws an error, but this does not render any breakcrumbs

{% block breadcrumbs %}
  {% breadcrumb customer 'customer-details' cust_id=customer.id %}
  {% breadcrumb customer 'contact-details' cust_id=customer.id contact_id=contact.id %}
{% endblock %}

{% block content %}
  bc{% render_breadcrumbs %}cb
  ...
{% endblock content %}

renders like image

The inspector shows it like: image

prymitive commented 10 years ago

can you retry with latest code from github?

prymitive commented 10 years ago

if it still doesn't work please paste contact-details and urls.py for it (only view definition, not full code), maybe I'm missing test case for it

mark0978 commented 10 years ago

Ok, the problem is one of documentation. Notice above how I have two blocks, one for breadcrumbs and one for content, you can't do that because you don't know which order the blocks will be rendered in. The docs need to say do all of it inline in one block like this:

  {% breadcrumb customer 'customer-details' cust_id=customer.id %}
  {% breadcrumb customer 'contact-details' cust_id=customer.id contact_id=contact.id %}
  {% render_breadcrumbs %}

This works as expected. I had to go thru the debugger to understand what was happening, but it really was this simple.

The kwargs problem was a real problem, this last issue was just documentation that wasn't explicit enough.

Even though the blocks were in the right order in this template, they were in a different order in the site base template and therefore they rendered incorrectly. In my case breadcrumbs were added AFTER they had been rendered.