rstudio / htmltools

Tools for HTML generation and output
https://rstudio.github.io/htmltools/
215 stars 68 forks source link

Don't assume all scripts are given as character variables. #321

Closed dmurdoch closed 2 years ago

dmurdoch commented 2 years ago

Also fixes the error message to only report missing files. Fixes #320.

cpsievert commented 2 years ago

Thanks @dmurdoch! If you don't mind, it'd also be great to have a unit test

dmurdoch commented 2 years ago

Sure, I'll see if I can add one.

dmurdoch commented 2 years ago

The last commit adds a test. It just tries to see if the function runs without error; I think other tests check that the results are okay.

dmurdoch commented 2 years ago

Just committed changes as per suggestions.

dmurdoch commented 2 years ago

Just a note in case there are more comments: I'm going offline soon, and won't be available for a week or two. I'll address other comments when I get back. If they're urgently needed before that, someone else will have to take over.

wch commented 2 years ago

I made some changes to the pluck_src function and merged into main manually.

wch commented 2 years ago

This would much simpler and easier to implement if the htmlDependency function normalized the shape of the data structures on the way in. We do it here in TypeScript: https://github.com/rstudio/shiny/blob/474f1400/srcts/src/shiny/render.ts#L355-L467. Maybe someday. Unfortunately, there might code out there that will break because it assumes the older format (just a character vector, not a list like script = list(src="abc")))