Thursday, July 19, 2012

Re: template filter to split string

You could create a custom template tag to do this. Then just do something like

{% load page_title %}
...
{{ page_title }}

Or create a context middleware that will always creates a variable with the proper data.

On Thu, Jul 19, 2012 at 12:36 PM, Markus Gattol <markus.gattol@gmail.com> wrote:
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.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
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