Thursday, July 19, 2012

template filter to split string

within the head section of my base.html I am using

        <title>
            {% block title %}
                {% if request.path_info == '/' %}
                    home
                {% else %}
                    {{ request.path_info | slugify }}
                {% endif %}
            {% endblock %}
        </title>

to set the title of a page. Certainly slugify isn't perfect so I am looking for a filter to turn the request.path string from e.g. /foo/baz/bar into bar Is there an easy way to do this or will I end up writing my own filter?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/qqi9dTGtc5UJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment