> On Tue, 28 Jul 2015, Cook, Malcolm wrote: > > > I have been playing with exporting htmlwidgets [1] generated in R code- > blocks. > > > > [snip: proposal for new :results format to accomodate repetitive codes] > > > > > > Perhaps there is a better or more useful abstraction. > > > > Or a better workaround than simply following the pattern when needed > (which is not too hard anyway). > > > > Any ideas along these lines? > > See > > (info "(org) Noweb reference syntax") > > for one way to handle repetitive codes. > > Alternately, header args :var, :post, :prologue and/or :epilogue could be used > to crystallize your code.
Excellent! Glad to be directed to these. The combination of all of them gets me over the fence: #+name: iframe #+begin_src sh :var it="" :var height="700px" :var width="700px" :results output :exports none printf "<iframe src=%s height=%s width=%s >" $it $height $width #+end_src #+header: :prologue {file="d3heatmap_widget.html"; saveWidget({ #+header: :epilogue },file) ;file} #+BEGIN_SRC R :session *R* :results html :exports both :post iframe(it=*this*,height="800px" width="800px") library(htmlwidgets) library(d3heatmap) d3heatmap(mtcars, scale="column", colors="Greens") #+END_SRC #+RESULTS: #+BEGIN_HTML <iframe src=d3heatmap_widget.html height=800px width=700px > #+END_HTML I don't really care for all the verbosity of the header, but the effect is perfect. The code block does not contain ANY extra org-mode export-specific cruft. TH, Malcolm > > One other alternative is to write an R function that creates the extra markup. > > HTH, > > Chuck