-
Notifications
You must be signed in to change notification settings - Fork 1.5k
display() should escape by default #915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Yeah, I think so... (with a few corners)
Why a class and not a method? |
Because the pyscript/pyscriptjs/src/python/pyscript.py Lines 49 to 58 in e04cf3c
I think that all the code around |
Yeah, agreed, we talked about that already (when chatting with @philippjfr) a few months ago when we were in Austin... we will probably need to revisit the implementation of that and [try to] keep the user-facing API unchanged.. It may be me (and may even being super pedantic).. don't really love the all caps |
I think that the official name of the language is |
|
Can someone approve this please? |

Before this PR,
display(some_str)anddisplay(some_obj)used to put the result directly in the.innerHTMLof the output element, without escaping.A notable effect is that
display(some_module)didn't display anything, because e.g.<module sys (built-in)>was interpreted as a tag by the HTML parser.This PR fixes it:
display(some_str)escapes the string by default. This is almost always what you wantdisplay(some_obj)callsrepr(obj)and escapes the result. Again, it's a very sensible defaultHTMLclass:display(HTML("<p>hello</p>")).I don't remember whether we wrote it down anywhere, but I'm pretty sure that this is what we decided in Austin when we talked in real life with @fpliger and @philippjfr .
Behavior on
main:Behavior with this PR:

Related issues:
HTML()class to let the user decide. If we really want we can still add the option to switch the default behavior, but I think that with this solution it might not be necessary.EDIT: I also had to delete
workflows/dashboard.yamlbecause it was failing and we are not using it anyway