Skip to content

Conversation

gshotwell
Copy link

This adds a JS class which we need for passing options to HTML tools. Since this class is currently identical to HTML I created a parent class RAW to hold that logic. I thought it was better to have HTML and JS as two child classes rather than as aliases in case we want to add HTML or JS specific methods (minify maybe?) down the road.


class JS(RAW):
"""
Mark a string as raw JavaScript.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Mark a string as raw JavaScript.
Mark a string as raw JavaScript. This will prevent the string from being escaped when
rendered inside an HTML tag.

Copy link
Collaborator

@jcheng5 jcheng5 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, is this not true? Now that I think about it, maybe it shouldn't be true? Or at least, JS() for the purposes of using inside tags.script() is very different than JS() for the purposes of marking certain parts of JSON-encoded options as needing to be evaluated in the client. We should not make it easy for users to mistakenly get the latter when they really just meant the former.

@gshotwell
Copy link
Author

We decided that this function was confusing in htmltools so are going to add a shiny-specific helper.

@gshotwell gshotwell closed this Jan 18, 2024
@gshotwell gshotwell deleted the JS-class branch January 22, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants