From dcd3fcdcc9b40b7774b4af9cd6f9bfd0c8c91986 Mon Sep 17 00:00:00 2001 From: stla Date: Wed, 23 Dec 2020 09:50:01 +0100 Subject: [PATCH] compliance with the new htmlwidgets convention --- inst/templates/widget_r.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/inst/templates/widget_r.txt b/inst/templates/widget_r.txt index 163ee64..81dcde2 100644 --- a/inst/templates/widget_r.txt +++ b/inst/templates/widget_r.txt @@ -21,6 +21,18 @@ ${name} <- function(message, width = NULL, height = NULL, elementId = NULL) { ) } +#' Called by HTMLWidgets to produce the widget's root element. +#' @noRd +widget_html.${name} <- function(id, style, class, ...) { + htmltools::tagList( + # Necessary for RStudio viewer version < 1.2 + reactR::html_dependency_corejs(), + reactR::html_dependency_react(), + reactR::html_dependency_reacttools(), + htmltools::tags$div(id = id, class = class, style = style) + ) +} + #' Shiny bindings for ${name} #' #' Output and render functions for using ${name} within Shiny @@ -48,15 +60,3 @@ render${capName} <- function(expr, env = parent.frame(), quoted = FALSE) { if (!quoted) { expr <- substitute(expr) } # force quoted htmlwidgets::shinyRenderWidget(expr, ${name}Output, env, quoted = TRUE) } - -#' Called by HTMLWidgets to produce the widget's root element. -#' @rdname ${name}-shiny -${name}_html <- function(id, style, class, ...) { - htmltools::tagList( - # Necessary for RStudio viewer version < 1.2 - reactR::html_dependency_corejs(), - reactR::html_dependency_react(), - reactR::html_dependency_reacttools(), - htmltools::tags$div(id = id, class = class, style = style) - ) -}