rstudio / htmltools

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

consider annotating dependency information #59

Open kevinushey opened 8 years ago

kevinushey commented 8 years ago

It would be useful if renderDependencies() annotated the injected <script> / <link> tags with data attributes describing the source of each dependency, e.g.

 <script
        data-name="htmlwidgets"
        data-version="0.6"
        data-script="htmlwidgets.js"
        data-stylesheet=""
        src="/path/to/R/library/htmlwidgets/www/htmlwidgets.js"></script>

This would make it possible to recover the source of a dependency after e.g. rmarkdown::render() is done with the document.

jcheng5 commented 8 years ago

I'm a little leery of putting the user library's absolute path in the html output, if the latter may be published somewhere. Can this be constrained to cases where we know the output isn't going anywhere?

kevinushey commented 8 years ago

Sorry, I should have been more clear -- all I'm advocating for is the inclusion of the data-* attributes, which should be easy to draw from the dependency information already passed into renderDependencies(). (The src field would just be whatever is normally passed in)

That said, this isn't high priority (there's a chance it may be useful in the R notebook work later on, but I don't think we'll need it for now)

yihui commented 8 years ago

Actually I wished the dependency object had a package attribute, and src could be resolved at a later time using system.file(src, package = package) (if the package name is provided). This will hide the absolute path, and make the dependencies more portable since they will be independent of the R library path.

jjallaire commented 8 years ago

I agree. I think this could be pretty seamlessly added (if there is a package attribute then src can be relative to the package).

On Fri, Apr 29, 2016 at 12:42 AM, Yihui Xie notifications@github.com wrote:

Actually I wished the dependency object had a package attribute, and src could be resolved at a later time using system.file(src, package = package) (if the package name is provided). This will hide the absolute path, and make the dependencies more portable since they will be independent of the R library path.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/rstudio/htmltools/issues/59#issuecomment-215625110