Skip to content

Commit

Permalink
Merge pull request #49 from stla/widget_html
Browse files Browse the repository at this point in the history
compliance with the new htmlwidgets convention
  • Loading branch information
timelyportfolio authored Feb 16, 2021
2 parents 41ceb50 + 9098b9c commit eef5d04
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions inst/templates/widget_r.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
#' @noRd
${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)
)
}

0 comments on commit eef5d04

Please sign in to comment.