Skip to content

Commit 2dd63d7

Browse files
AmeliaMNhadley
authored andcommitted
Add requireNamespace so str_view() fails more gracefully (#273)
Fixes #263
1 parent e8bec70 commit 2dd63d7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

R/view.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ str_view_widget <- function(lines) {
7575
)
7676
html <- htmltools::HTML(bullets)
7777

78+
if (!requireNamespace("htmlwidgets", quietly = TRUE)) {
79+
stop("htmlwidgets package required for str_view(). \nPlease install.packages(\"htmlwidgets\") to use this functionality.",
80+
call. = FALSE)
81+
}
7882
size <- htmlwidgets::sizingPolicy(
7983
knitr.figure = FALSE,
8084
defaultHeight = pmin(10 * length(lines), 300),

0 commit comments

Comments
 (0)