Skip to content

Commit eef5d04

Browse files
Merge pull request #49 from stla/widget_html
compliance with the new htmlwidgets convention
2 parents 41ceb50 + 9098b9c commit eef5d04

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

inst/templates/widget_r.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ ${name} <- function(message, width = NULL, height = NULL, elementId = NULL) {
2121
)
2222
}
2323

24+
#' Called by HTMLWidgets to produce the widget's root element.
25+
#' @noRd
26+
widget_html.${name} <- function(id, style, class, ...) {
27+
htmltools::tagList(
28+
# Necessary for RStudio viewer version < 1.2
29+
reactR::html_dependency_corejs(),
30+
reactR::html_dependency_react(),
31+
reactR::html_dependency_reacttools(),
32+
htmltools::tags$div(id = id, class = class, style = style)
33+
)
34+
}
35+
2436
#' Shiny bindings for ${name}
2537
#'
2638
#' Output and render functions for using ${name} within Shiny
@@ -48,15 +60,3 @@ render${capName} <- function(expr, env = parent.frame(), quoted = FALSE) {
4860
if (!quoted) { expr <- substitute(expr) } # force quoted
4961
htmlwidgets::shinyRenderWidget(expr, ${name}Output, env, quoted = TRUE)
5062
}
51-
52-
#' Called by HTMLWidgets to produce the widget's root element.
53-
#' @noRd
54-
${name}_html <- function(id, style, class, ...) {
55-
htmltools::tagList(
56-
# Necessary for RStudio viewer version < 1.2
57-
reactR::html_dependency_corejs(),
58-
reactR::html_dependency_react(),
59-
reactR::html_dependency_reacttools(),
60-
htmltools::tags$div(id = id, class = class, style = style)
61-
)
62-
}

0 commit comments

Comments
 (0)