On 4/10/2013 12:21am, Bill Freeman wrote:
You can certainly write a custom filter. And if you do that, you can divvy up your value into footnote links and other, and escape the other parts yourself, returning the result as a safe string.
So you mean I detect any non-footnote html in the custom filter myself and convert it to Klingon but add my own html for footnotes and flag all such fields as safe?
Hadn't thought of that. Might investigate calling the Django safe filter from within the custom filter ...
Great idea, thanks Mike
On Thu, Oct 3, 2013 at 2:55 AM, Mike Dewhirst <mi...@dewhirst.com.au <mailto:mi...@dewhirst.com.au>> wrote: I made a custom template filter (ref_href) which converts numbered references (like [1], [2] etc) into footnote hyperlinks. It works but requires the |safe filter which is dangerous. To be actually safe I want to *only* use the |safe filter when the data contains a numbered reference. Which I cannot do if it is permanently in the template. In other words, I want to remove the |safe filter from the template and incorporate it into my custom filter which checks that we have an integer between the square brackets before doing its work. Just thinking about it now, I suppose I could put a conditional in the template ... {% if "[" in value %} {{ value | ref_href | safe }} {% else %} {{ value }} {% endif %} ... but that's a lot of typing over dozens of templates. And it isn't good enough. Thanks for any secrets Mike -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@__googlegroups.com <mailto:django-users%2bunsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>. Visit this group at http://groups.google.com/__group/django-users <http://groups.google.com/group/django-users>. To view this discussion on the web visit https://groups.google.com/d/__msgid/django-users/524D14D9.__5090605%40dewhirst.com.au <https://groups.google.com/d/msgid/django-users/524D14D9.5090605%40dewhirst.com.au>. For more options, visit https://groups.google.com/__groups/opt_out <https://groups.google.com/groups/opt_out>. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAB%2BAj0uMUVFmHGY%3DYckq_e03ve1WhKG29ruCUWRU2zaVuFsN2Q%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/524E0163.7010406%40dewhirst.com.au. For more options, visit https://groups.google.com/groups/opt_out.