shinyjs icon indicating copy to clipboard operation
shinyjs copied to clipboard

`extendShinyjs(script = htmlDependency(...), functions = ...)` support

Open mmuurr opened this issue 1 year ago • 6 comments

I'm wondering if there's a simple way to specify the script file holding {shinyjs} 'extension' functions as an {htmltools} htmlDependency object, using then the absolute file resolution codepath of that dependency.

I realize addResourcePath() does something similar already, but as I write some standardized wrappers I was just curious if htmlDependency() had ever been considered :-)

Cheers and thanks!

mmuurr avatar Aug 09 '22 20:08 mmuurr

I haven't thought of this before, so it's not supported. The only reason it's not supported is because this function was written many years ago before I understood how htmlDependency() works. This would be a good idea if anyone wants to try to implement it.

daattali avatar Aug 15 '22 04:08 daattali

@mmuurr This should now be supported, you can use the script argument with an htmlDependency. Can you please let me know if it works for you?

Note to self: before closing the issue, update documentation anywhere that addResourcePath is used or where extendShinyjs is used

daattali avatar Jan 16 '23 09:01 daattali

@daattali,

This should not be supported ...

I assume that's a typo and it actually should be, "This should now be supported"; correct?

(It's a shame that two dramatically different meanings are separable by only one character :-))

mmuurr avatar Jan 18 '23 17:01 mmuurr

I should not be writing messages (or even worse, coding) at 4:50am... yet here we are. Hopefully the code was better than the message. Can you please verify that this works for you?

daattali avatar Jan 18 '23 18:01 daattali

Yup, this seems to be working for me now; thanks!

(I still always struggle with the various options of htmlDependency() itself and how to get the output HTML tags to what I want, but that's {htmltools}' issue and the challenges that come with heavily-overloading a single function's optional parameters :-| )

mmuurr avatar Jan 22 '23 21:01 mmuurr

Oh I also do! Every single time I need to use htmlDependency(), I do a github serach through my own repos to see how to use it. Every single time.

daattali avatar Jan 23 '23 06:01 daattali