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

Unable to past HTML as label #7

Closed Edke closed 11 years ago

Edke commented 11 years ago

My issue interfere with pull request in #6, but anyway, there are cases when I need to show for example icon and not a plain text as a label:

{% block breadcrumbs %}
    {% breadcrumb '<i class="icon-home"></i>' 'myapp.views.home' %}
{% endblock %}

I would be pleased if this would also be possible.

prymitive commented 11 years ago

2 options:

add _safe variant of breadcrumb tag:

{% block breadcrumbs %}
    {% breadcrumb_safe '<i class="icon-home"></i>' 'myapp.views.home' %}
{% endblock %}

or we could have label part inside of a block, so you could control escaping explicitly using django utils, bonus is that block allows you to use whatever logic you need there:

{% block breadcrumbs %}
    {% breadcrumb_for 'myapp.views.home' %}
        {% autoescape on/off %}
            '<i class="icon-home"></i>'
        {% endautoescape %}
     {% endbreadcrumb_for %}
{% endblock %}

I can add both, so that you will only need to sed s/"{% breadcrumb"/"{% breadcrumb_safe"/g in your code and only move to breadcrumb_for where you need it.

prymitive commented 11 years ago

pushed 0.3.2 with breadcrumb_safe, I'll add 0.4.0 with breadcrumb_for later

Edke commented 11 years ago

@prymitive breadcrumbs_safe will do just fine, breadcrumbs_for is just a bonus. Thank you for both and also for lightning fast response and pushing new version with fix. I can see again my lovely house icon in my breadcrumbs since upgrade :) Thanks.

prymitive commented 11 years ago

happy to help, I've just released 0.4.0 with breadcrumb_for block tag, you can used for more complex stuff