Closed abingham closed 3 months ago
This has already been discussed here https://github.com/leforestier/yattag/pull/21 and I decided to limit the automatic stringification to numerical values. To sum it up, this is to catch programming mistakes early, and to help people avoid leaking potentially sensitive data on the internet by mistake (by accidentally printing a full dictionary instead of one of its entries for example).
Ok, that's fair enough, and I can probably subclass Doc to get what I'm talking about if I really want.
SimpleDoc.text()
currently only accepts objects of typestr
,int
, andfloat
. So if I have objects of other types that have__str__
representations I want to use, I have to stringify them before passing them intotext()
. This is a bit error prone (i.e. I forget to do it and get an exception), it clutters my code a bit, and I don't really see what's gained by not internally stringifying the arguments totext()
.So could we update
SimpleDoc.text()
to accept objects of any sort, having it callstr()
on them before callinghtml_escape()
? Or is there an important reason that we limit the API tostr
,float
, andint
?