W dniu wtorek, 26 września 2017 14:34:29 UTC+2 użytkownik Jonas H napisał:
>
> Proposal: Support the __html__ method as an alternative/addition to the 
> __str__ for turning objects into strings in the template layer.
>
> If this has been discussed before, please point me to it; I couldn't find 
> anything with the search function.
>
> Some custom classes may have, in addition to a __str__ representation, a 
> natural representation that is better suited for HTML output.
>

Another proposal:

Introduce a single-dispatch html function (
https://docs.python.org/3/library/functools.html#functools.singledispatch).

Have the default implementation call param.__html__() if it exists and fall 
back to param.__str__().

Document using html.register(...) as the preferred extension method.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/429010b7-7606-4f57-b4ca-c449005dfa32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to