#33692: urlize to accept target attribute as parameter
-----------------------------------+--------------------------------------
     Reporter:  Timothy Schilling  |                    Owner:  nobody
         Type:  New feature        |                   Status:  new
    Component:  Template system    |                  Version:
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------

Comment (by Carlton Gibson):

 Stack Overflow has a suggestion here:


 {{{
 # <app name>/templatetags/url_target_blank.py

 from django import template
 register = template.Library()

 def url_target_blank(text):
     return text.replace('<a ', '<a target="_blank" ')

 url_target_blank = register.filter(url_target_blank, is_safe = True)

 }}}

 Example of usage:


 {{{
 {% load url_target_blank %}
 ...
 {{ post_body|urlize|url_target_blank }}

 }}}

 https://stackoverflow.com/questions/2295725/extending-urlize-in-django

 I don't know if that's good enough finally, or whether it's worth adding
 the API here, but it would serve as a workaround.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33692#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070180b2110210-e6c4a76d-a78e-4edd-bdba-48f61f9df526-000000%40eu-central-1.amazonses.com.

Reply via email to