ramnathv/htmlwidgets — pull request #12 by jjallaire (2014-08-06 20:54:11+00:00)
Title: makeShinyOutput and makeShinyRender utilty functions

These new functions replace the widgetOutput and renderWidget functions. Rather than provide direct implementations of these functions these new implementations return a function that can be assigned. e.g. see https://github.com/jjallaire/networkD3/blob/master/R/simpleNetwork.R#L126-L132

These functions overcome two limitations of the previous implementation:

1. In the case of widgetOutput, a defaultHeight and defaultWidth can be provided and the returned function will correctly show these in usage sections generated by roxygen.

2. In the case of renderWidget, the shiny markRenderFunction function is called to associate an output function with the render function (this is necessary for widgets to work within Rmd files with `runtime: shiny`).

Note that this implementation does require that each widget have it's own distinct output and render function (whereas in the previous implementation htmlwidgets::widgetOutput and htmlwidgets::renderWidget could have been used instead). While avoiding the definition of widget and output functions entirely was nice, it would have required end users to (a) explicitly call htmlwidgets (which is really an implementation detail); and (b) understand the abstraction that they are just rendering a "widget" (which could be anything) as distinct from renderPlot, renderTable, etc. I think it's better from a clarity standpoint if the various widget types have their own functions.