-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow html content to be added to a report (#294)
- Loading branch information
Showing
20 changed files
with
446 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#' @title `HTMLBlock` | ||
#' @docType class | ||
#' @description | ||
#' Specialized `FileBlock` for managing HTML content in reports. | ||
#' It's designed to handle various HTML content, and render the report as HTML, | ||
#' however `htmlwidgets` objects can also be rendered to static document-ready format. | ||
#' | ||
#' @keywords internal | ||
HTMLBlock <- R6::R6Class( # nolint: object_name_linter. | ||
classname = "HTMLBlock", | ||
inherit = ContentBlock, | ||
public = list( | ||
#' @description Initialize a `HTMLBlock` object. | ||
#' | ||
#' @param content An object that can be rendered as a HTML content assigned to | ||
#' this `HTMLBlock` | ||
#' | ||
#' @return Object of class `HTMLBlock`, invisibly. | ||
initialize = function(content) { | ||
if (!missing(content)) { | ||
checkmate::assert_multi_class(content, private$supported_types) | ||
self$set_content(content) | ||
} | ||
invisible(self) | ||
}, | ||
|
||
#' @description Create the `HTMLBlock` from a list. | ||
#' | ||
#' @param x (`named list`) with a single field `content` containing `shiny.tag`, | ||
#' `shiny.tag.list` or `htmlwidget`. | ||
#' | ||
#' @return `self`, invisibly. | ||
#' @examples | ||
#' HTMLBlock <- getFromNamespace("HTMLBlock", "teal.reporter") | ||
#' block <- HTMLBlock$new() | ||
#' block$from_list(list(content = shiny::tags$div("test"))) | ||
#' | ||
from_list = function(x) { | ||
checkmate::assert_list(x, types = private$supported_types) | ||
checkmate::assert_names(names(x), must.include = "content") | ||
self$set_content(x$content) | ||
invisible(self) | ||
}, | ||
|
||
#' @description Convert the `HTMLBlock` to a list. | ||
#' | ||
#' @return `named list` with a text and style. | ||
#' @examples | ||
#' HTMLBlock <- getFromNamespace("HTMLBlock", "teal.reporter") | ||
#' block <- HTMLBlock$new(shiny::tags$div("test")) | ||
#' block$to_list() | ||
#' | ||
to_list = function() { | ||
list(content = self$get_content()) | ||
} | ||
), | ||
private = list( | ||
supported_types = c("shiny.tag", "shiny.tag.list", "htmlwidget") | ||
), | ||
lock_objects = TRUE, | ||
lock_class = TRUE | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.