| Title: | Reporting Tools for 'shiny' Modules |
|---|---|
| Description: | Prebuilt 'shiny' modules containing tools for the generation of 'rmarkdown' reports, supporting reproducible research and analysis. |
| Authors: | Dawid Kaledkowski [aut, cre] (ORCID: <https://orcid.org/0000-0001-9533-457X>), Kartikeya Kirar [aut] (ORCID: <https://orcid.org/0009-0005-1258-4757>), Marcin Kosinski [aut], Maciej Nasinski [aut], Konrad Pagacz [aut], Mahmoud Hallal [aut], Chendi Liao [rev], Dony Unardi [rev], F. Hoffmann-La Roche AG [cph, fnd] |
| Maintainer: | Dawid Kaledkowski <[email protected]> |
| License: | Apache License 2.0 |
| Version: | 0.6.1 |
| Built: | 2026-05-21 03:19:03 UTC |
| Source: | https://github.com/insightsengineering/teal.reporter |
Provides a button to add views/cards to a report.
For more details see the vignette: vignette("simpleReporter", "teal.reporter").
add_card_button_ui(id, label = NULL) add_card_button_srv(id, reporter, card_fun, card_title = "")add_card_button_ui(id, label = NULL) add_card_button_srv(id, reporter, card_fun, card_title = "")
id |
( |
label |
( |
reporter |
( |
card_fun |
( |
card_title |
( |
The card_fun function is designed to create a new ReportCard instance and optionally customize it:
The teal_card parameter allows for specifying a custom or default ReportCard instance.
Use the comment parameter to add a comment to the card via card$append_text() - if card_fun does not
have the comment parameter, then comment from Add Card UI module will be added at the end of the content of the
card.
The label parameter enables customization of the card's name and its content through card$append_text()-
if card_fun does not have the label parameter, then card name will be set to the name passed in
Add Card UI module, but no text will be added to the content of the teal_card.
This module supports using a subclass of ReportCard for added flexibility.
A subclass instance should be passed as the default value of
the teal_card argument in the card_fun function.
See below:
CustomReportCard <- R6::R6Class(
classname = "CustomReportCard",
inherit = teal.reporter::ReportCard
)
custom_function <- function(card = CustomReportCard$new()) {
card
}
NULL.
yaml header for an Rmd fileConverts a named list into a yaml header for Rmd, handling output types and arguments
as defined in the rmarkdown package. This function simplifies the process of generating yaml headers.
as_yaml_auto( input_list, as_header = TRUE, convert_logi = TRUE, multi_output = FALSE, silent = FALSE )as_yaml_auto( input_list, as_header = TRUE, convert_logi = TRUE, multi_output = FALSE, silent = FALSE )
input_list |
( |
as_header |
( |
convert_logi |
( |
multi_output |
( |
silent |
( |
This function processes a non-nested (flat) named list into a yaml header for an Rmd document.
It supports all standard Rmd yaml header fields, including author, date, title, subtitle,
abstract, keywords, subject, description, category, and lang.
Additionally, it handles output field types and arguments as defined in the rmarkdown package.
character with rmd_yaml_header class,
result of yaml::as.yaml, optionally wrapped with internal md_header().
Only non-nested lists are automatically parsed.
Nested lists require direct processing with yaml::as.yaml.
# nested so using yaml::as.yaml directly as_yaml_auto( list(author = "", output = list(pdf_document = list(toc = TRUE))) ) # auto parsing for a flat list, like shiny input input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE) as_yaml_auto(input) as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = "TRUE")) as_yaml_auto(list( author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE, wrong = 2 )) as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = 2), silent = TRUE ) input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = "True") as_yaml_auto(input) as_yaml_auto(input, convert_logi = TRUE, silent = TRUE) as_yaml_auto(input, silent = TRUE) as_yaml_auto(input, convert_logi = FALSE, silent = TRUE) as_yaml_auto( list( author = "", output = "pdf_document", output = "html_document", toc = TRUE, keep_tex = TRUE ), multi_output = TRUE ) as_yaml_auto( list( author = "", output = "pdf_document", output = "html_document", toc = "True", keep_tex = TRUE ), multi_output = TRUE )# nested so using yaml::as.yaml directly as_yaml_auto( list(author = "", output = list(pdf_document = list(toc = TRUE))) ) # auto parsing for a flat list, like shiny input input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE) as_yaml_auto(input) as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = "TRUE")) as_yaml_auto(list( author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE, wrong = 2 )) as_yaml_auto(list(author = "", output = "pdf_document", toc = TRUE, keep_tex = 2), silent = TRUE ) input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = "True") as_yaml_auto(input) as_yaml_auto(input, convert_logi = TRUE, silent = TRUE) as_yaml_auto(input, silent = TRUE) as_yaml_auto(input, convert_logi = FALSE, silent = TRUE) as_yaml_auto( list( author = "", output = "pdf_document", output = "html_document", toc = TRUE, keep_tex = TRUE ), multi_output = TRUE ) as_yaml_auto( list( author = "", output = "pdf_document", output = "html_document", toc = "True", keep_tex = TRUE ), multi_output = TRUE )
teal_report objectsConcatenate teal_report objects
## S3 method for class 'teal_report' c(...)## S3 method for class 'teal_report' c(...)
... |
( |
A teal_report object with combined teal_card elements.
This function creates a code_chunk object that represents code to be displayed
in a report. It stores the code of any language (see lang argument) and any
specified chunk options (e.g., echo, eval).
code_chunk(code, ..., lang = "R")code_chunk(code, ..., lang = "R")
code |
( |
... |
Additional named parameters to be included as chunk options. These control
how the chunk behaves when rendered (e.g., |
lang |
( |
Important Notes:
The code is not evaluated; it is only stored as text with formatting attributes.
When converted to output, code_chunk produces markdown code block syntax
(```{lang} ... ```) or HTML <pre><code>...</code></pre> blocks.
The document is not rendered using rmarkdown::render. The code_chunk is part
of the teal_card API for building reproducible documents that are produced as-is.
Typical Workflow:
Create a code_chunk object with your code and options
Add it to a teal_card using teal_card() or c()
The card produces the formatted code block in the final document output
An object of class code_chunk
teal_card() for creating report cards that can contain code_chunk objects
# Basic code chunk with options code_chunk("x <- 1:10", echo = TRUE, message = FALSE) # Python code chunk code_chunk("import pandas as pd", lang = "python", eval = FALSE) # Code chunk with multiple knitr options code_chunk( "plot(mtcars$mpg, mtcars$hp)", echo = TRUE, eval = TRUE, fig.width = 7, fig.height = 5, warning = FALSE )# Basic code chunk with options code_chunk("x <- 1:10", echo = TRUE, message = FALSE) # Python code chunk code_chunk("import pandas as pd", lang = "python", eval = FALSE) # Code chunk with multiple knitr options code_chunk( "plot(mtcars$mpg, mtcars$hp)", echo = TRUE, eval = TRUE, fig.width = 7, fig.height = 5, warning = FALSE )
Provides a button that triggers downloading a report.
For more information, refer to the vignette: vignette("simpleReporter", "teal.reporter").
download_report_button_ui(id, label = NULL) download_report_button_srv( id, reporter, global_knitr = getOption("teal.reporter.global_knitr"), rmd_output = getOption("teal.reporter.rmd_output"), rmd_yaml_args = getOption("teal.reporter.rmd_yaml_args") )download_report_button_ui(id, label = NULL) download_report_button_srv( id, reporter, global_knitr = getOption("teal.reporter.global_knitr"), rmd_output = getOption("teal.reporter.rmd_output"), rmd_yaml_args = getOption("teal.reporter.rmd_yaml_args") )
id |
( |
label |
( |
reporter |
( |
global_knitr |
( |
rmd_output |
( |
rmd_yaml_args |
( |
To access the default values for the global_knitr parameter,
use getOption('teal.reporter.global_knitr'). These defaults include:
echo = TRUE
tidy.opts = list(width.cutoff = 60)
tidy = TRUE if formatR package is installed, FALSE otherwise
NULL.
qenv
Evaluate code in qenv
## S4 method for signature 'teal_report' eval_code(object, code, code_block_opts = list(), ...)## S4 method for signature 'teal_report' eval_code(object, code, code_block_opts = list(), ...)
object |
( |
code |
( |
code_block_opts |
( |
... |
( |
eval_code() evaluates given code in the qenv environment and appends it to the code slot.
Thus, if the qenv had been instantiated empty, contents of the environment are always a result of the stored code.
teal_reporter environment with the code evaluated and the outputs added
to the card or qenv.error if evaluation fails.
td <- teal.data::teal_data() td <- teal.code::eval_code(td, "iris <- iris") tr <- as.teal_report(td) tr <- teal.code::eval_code(tr, "a <- 1") tr <- teal.code::eval_code(tr, "b <- 2L # with comment") tr <- teal.code::eval_code(tr, quote(library(checkmate))) tr <- teal.code::eval_code(tr, expression(assert_number(a))) teal_card(tr)td <- teal.data::teal_data() td <- teal.code::eval_code(td, "iris <- iris") tr <- as.teal_report(td) tr <- teal.code::eval_code(tr, "a <- 1") tr <- teal.code::eval_code(tr, "b <- 2L # with comment") tr <- teal.code::eval_code(tr, quote(library(checkmate))) tr <- teal.code::eval_code(tr, expression(assert_number(a))) teal_card(tr)
Reporter button moduleProvides a button to upload ReporterCard(s) to the Reporter.
For more information, refer to the vignette: vignette("simpleReporter", "teal.reporter").
report_load_ui(id, label = NULL) report_load_srv(id, reporter)report_load_ui(id, label = NULL) report_load_srv(id, reporter)
id |
|
label |
( |
reporter |
|
shiny::tagList
shiny::moduleServer
teal_card or ReportCard
This function retrieves metadata from a teal_card or ReportCard object.
When which is NULL, it returns all metadata fields as a list.
metadata(object, which = NULL) ## S3 method for class 'teal_card' metadata(object, which = NULL) ## S3 method for class 'ReportCard' metadata(object, which = NULL)metadata(object, which = NULL) ## S3 method for class 'teal_card' metadata(object, which = NULL) ## S3 method for class 'ReportCard' metadata(object, which = NULL)
object |
( |
which |
( |
A list of metadata fields or a specific field if which is provided.
teal_card or ReportCard
This function allows you to set or modify metadata fields in a teal_card or ReportCard object.
It can be used to add new metadata or update existing fields.
metadata(object, which = NULL) <- value ## S3 replacement method for class 'teal_card' metadata(object, which = NULL) <- value ## S3 replacement method for class 'ReportCard' metadata(object, which) <- valuemetadata(object, which = NULL) <- value ## S3 replacement method for class 'teal_card' metadata(object, which = NULL) <- value ## S3 replacement method for class 'ReportCard' metadata(object, which) <- value
object |
( |
which |
( |
value |
The value to assign to the specified metadata field. |
The ReportCard class only supports the title field in metadata.
The modified object with updated metadata.
yaml_header classPrint method for the yaml_header class
## S3 method for class 'rmd_yaml_header' print(x, ...)## S3 method for class 'rmd_yaml_header' print(x, ...)
x |
( |
... |
optional text. |
NULL.
input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE) out <- as_yaml_auto(input) out print(out)input <- list(author = "", output = "pdf_document", toc = TRUE, keep_tex = TRUE) out <- as_yaml_auto(input) out print(out)
teal_card
Render teal_card
render( input, output_dir = getwd(), global_knitr = getOption("teal.reporter.global_knitr"), keep_rmd = TRUE, ... )render( input, output_dir = getwd(), global_knitr = getOption("teal.reporter.global_knitr"), keep_rmd = TRUE, ... )
input |
( |
output_dir |
The output directory for the rendered |
global_knitr |
( |
keep_rmd |
( |
... |
arguments passed to |
report <- teal_report() teal_card(report) <- c( teal_card(report), "## Document section", "Lorem ipsum dolor sit amet" ) report <- within(report, a <- 2) report <- within(report, plot(a)) metadata(teal_card(report)) <- list( title = "My Document", author = "NEST" ) if (interactive()) { render(report, output_format = rmarkdown::pdf_document(), global_knitr = list(fig.width = 10)) }report <- teal_report() teal_card(report) <- c( teal_card(report), "## Document section", "Lorem ipsum dolor sit amet" ) report <- within(report, a <- 2) report <- within(report, plot(a)) metadata(teal_card(report)) <- list( title = "My Document", author = "NEST" ) if (interactive()) { render(report, output_format = rmarkdown::pdf_document(), global_knitr = list(fig.width = 10)) }
ReportCard: An R6 class for building report elementsThis R6 class that supports creating a report card containing text, plot, table and
metadata blocks that can be appended and rendered to form a report output from a shiny app.
This class is deprecated. Use teal_report class instead for new implementations.
See vignette("teal-report-class", "teal.reporter") for more information.
new()
Initialize a ReportCard object.
ReportCard$new()
Object of class ReportCard, invisibly.
card <- ReportCard$new()
append_table()
Appends a table to this ReportCard.
ReportCard$append_table(table)
tableA (data.frame or rtables or TableTree or ElementaryTable or listing_df)
that can be coerced into a table.
self, invisibly.
card <- ReportCard$new()$append_table(iris)
append_html()
Appends a html content to this ReportCard.
ReportCard$append_html(content)
contentAn object that can be rendered as a HTML content.
self, invisibly.
card <- ReportCard$new()$append_html(shiny::div("HTML Content"))
append_plot()
Appends a plot to this ReportCard.
ReportCard$append_plot(plot, dim = NULL)
plot(ggplot or grob or trellis) plot object.
dim(numeric(2)) width and height in pixels.
self, invisibly.
append_text()
Appends a text paragraph to this ReportCard.
ReportCard$append_text(
text,
style = c("default", "header2", "header3", "verbatim")
)text(character) The text content to add.
style(character(1)) the style of the paragraph.
self, invisibly.
card <- ReportCard$new()$append_text("A paragraph of default text")
append_rcode()
Appends an R code chunk to ReportCard.
ReportCard$append_rcode(text, ...)
text(character) The R code to include.
...Additional rmarkdown parameters for formatting the R code chunk.
self, invisibly.
card <- ReportCard$new()$append_rcode("2+2", echo = FALSE)
append_content()
Appends a generic content to this ReportCard.
ReportCard$append_content(content)
content(Object.)
self, invisibly.
card <- ReportCard$new()$append_content(code_chunk("foo <- 2"))
get_content()
Get all content blocks from this ReportCard.
ReportCard$get_content()
teal_card() containing appended elements.
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_content()
reset()
Clears all content and metadata from ReportCard.
ReportCard$reset()
self, invisibly.
get_metadata()
Get the metadata associated with ReportCard.
ReportCard$get_metadata()
named list list of elements.
card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2")
card$get_metadata()
append_metadata()
Appends metadata to this ReportCard.
ReportCard$append_metadata(key, value)
key(character(1)) string specifying the metadata key.
valuevalue associated with the metadata key.
self, invisibly.
get_name()
Get the name of the ReportCard.
ReportCard$get_name()
character a card name.
ReportCard$new()$set_name("NAME")$get_name()
set_name()
Set the name of the ReportCard.
ReportCard$set_name(name)
name(character(1)) a card name.
self, invisibly.
ReportCard$new()$set_name("NAME")$get_name()
set_content_names()
Set content block names for compatibility with newer teal_card
ReportCard$set_content_names(new_names)
new_names(character) vector of new names.
to_list()
Convert the ReportCard to a list, including content and metadata.
ReportCard$to_list(output_dir = lifecycle::deprecated())
output_dir(character) with a path to the directory where files will be copied.
(named list) a ReportCard representation.
from_list()
Reconstructs the ReportCard from a list representation.
ReportCard$from_list(card, output_dir = lifecycle::deprecated())
card(named list) a ReportCard representation.
output_dir(character) with a path to the directory where a file will be copied.
self, invisibly.
clone()
The objects of this class are cloneable with this method.
ReportCard$clone(deep = FALSE)
deepWhether to make a deep clone.
library(ggplot2) card <- ReportCard$new()$append_plot( ggplot(iris, aes(x = Petal.Length)) + geom_histogram() ) library(ggplot2) card <- ReportCard$new()$append_text("Some text")$append_plot( ggplot(iris, aes(x = Petal.Length)) + geom_histogram() )$append_text("Some text")$append_metadata(key = "lm", value = lm(Ozone ~ Solar.R, airquality)) card$get_content() card$get_metadata() library(ggplot2) card <- ReportCard$new()$append_text("Some text")$append_plot( ggplot(iris, aes(x = Petal.Length)) + geom_histogram() )$append_text("Some text")$append_metadata(key = "lm", value = lm(Ozone ~ Solar.R, airquality)) card$get_content() card$to_list(tempdir()) library(ggplot2) card <- ReportCard$new()$append_text("Some text")$append_plot( ggplot(iris, aes(x = Petal.Length)) + geom_histogram() )$append_text("Some text")$append_metadata(key = "lm", value = lm(Ozone ~ Solar.R, airquality)) card$get_content() ReportCard$new()$from_list(card$to_list(tempdir()), tempdir()) ## ------------------------------------------------ ## Method `ReportCard$new` ## ------------------------------------------------ card <- ReportCard$new() ## ------------------------------------------------ ## Method `ReportCard$append_table` ## ------------------------------------------------ card <- ReportCard$new()$append_table(iris) ## ------------------------------------------------ ## Method `ReportCard$append_html` ## ------------------------------------------------ card <- ReportCard$new()$append_html(shiny::div("HTML Content")) ## ------------------------------------------------ ## Method `ReportCard$append_text` ## ------------------------------------------------ card <- ReportCard$new()$append_text("A paragraph of default text") ## ------------------------------------------------ ## Method `ReportCard$append_rcode` ## ------------------------------------------------ card <- ReportCard$new()$append_rcode("2+2", echo = FALSE) ## ------------------------------------------------ ## Method `ReportCard$append_content` ## ------------------------------------------------ card <- ReportCard$new()$append_content(code_chunk("foo <- 2")) ## ------------------------------------------------ ## Method `ReportCard$get_content` ## ------------------------------------------------ card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2") card$get_content() ## ------------------------------------------------ ## Method `ReportCard$get_metadata` ## ------------------------------------------------ card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2") card$get_metadata() ## ------------------------------------------------ ## Method `ReportCard$get_name` ## ------------------------------------------------ ReportCard$new()$set_name("NAME")$get_name() ## ------------------------------------------------ ## Method `ReportCard$set_name` ## ------------------------------------------------ ReportCard$new()$set_name("NAME")$get_name()library(ggplot2) card <- ReportCard$new()$append_plot( ggplot(iris, aes(x = Petal.Length)) + geom_histogram() ) library(ggplot2) card <- ReportCard$new()$append_text("Some text")$append_plot( ggplot(iris, aes(x = Petal.Length)) + geom_histogram() )$append_text("Some text")$append_metadata(key = "lm", value = lm(Ozone ~ Solar.R, airquality)) card$get_content() card$get_metadata() library(ggplot2) card <- ReportCard$new()$append_text("Some text")$append_plot( ggplot(iris, aes(x = Petal.Length)) + geom_histogram() )$append_text("Some text")$append_metadata(key = "lm", value = lm(Ozone ~ Solar.R, airquality)) card$get_content() card$to_list(tempdir()) library(ggplot2) card <- ReportCard$new()$append_text("Some text")$append_plot( ggplot(iris, aes(x = Petal.Length)) + geom_histogram() )$append_text("Some text")$append_metadata(key = "lm", value = lm(Ozone ~ Solar.R, airquality)) card$get_content() ReportCard$new()$from_list(card$to_list(tempdir()), tempdir()) ## ------------------------------------------------ ## Method `ReportCard$new` ## ------------------------------------------------ card <- ReportCard$new() ## ------------------------------------------------ ## Method `ReportCard$append_table` ## ------------------------------------------------ card <- ReportCard$new()$append_table(iris) ## ------------------------------------------------ ## Method `ReportCard$append_html` ## ------------------------------------------------ card <- ReportCard$new()$append_html(shiny::div("HTML Content")) ## ------------------------------------------------ ## Method `ReportCard$append_text` ## ------------------------------------------------ card <- ReportCard$new()$append_text("A paragraph of default text") ## ------------------------------------------------ ## Method `ReportCard$append_rcode` ## ------------------------------------------------ card <- ReportCard$new()$append_rcode("2+2", echo = FALSE) ## ------------------------------------------------ ## Method `ReportCard$append_content` ## ------------------------------------------------ card <- ReportCard$new()$append_content(code_chunk("foo <- 2")) ## ------------------------------------------------ ## Method `ReportCard$get_content` ## ------------------------------------------------ card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2") card$get_content() ## ------------------------------------------------ ## Method `ReportCard$get_metadata` ## ------------------------------------------------ card <- ReportCard$new()$append_text("Some text")$append_metadata("rc", "a <- 2 + 2") card$get_metadata() ## ------------------------------------------------ ## Method `ReportCard$get_name` ## ------------------------------------------------ ReportCard$new()$set_name("NAME")$get_name() ## ------------------------------------------------ ## Method `ReportCard$set_name` ## ------------------------------------------------ ReportCard$new()$set_name("NAME")$get_name()
Reporter: An R6 class for managing reportsThis R6 class is designed to store and manage reports,
facilitating the creation, manipulation, and serialization of report-related data.
It supports both ReportCard and teal_card objects, allowing flexibility
in the types of reports that can be stored and managed.
new()
Initialize a Reporter object.
Reporter$new()
Object of class Reporter, invisibly.
reporter <- Reporter$new()
append_cards()
Append one or more ReportCard or teal_card objects to the Reporter.
Reporter$append_cards(cards)
cards(ReportCard or teal_card) or a list of such objects
self, invisibly.
reorder_cards()
Reorders teal_card objects in Reporter.
Reorders teal_card objects in Reporter.
Reporter$reorder_cards(new_order)
new_ordercharacter vector with names of teal_card objects to
be set in this order.
self, invisibly.
replace_card()
Sets ReportCard or teal_card content.
Reporter$replace_card(card, card_id)
cardThe new object (ReportCard or teal_card) to replace the existing one.
card_id(character(1)) the unique id of the card to be replaced.
self, invisibly.
get_cards()
Retrieves all teal_card objects contained in Reporter.
Reporter$get_cards()
A (list) of teal_card objects.
get_blocks()
Compiles and returns all content blocks from the teal_card
objects in the Reporter.
Reporter$get_blocks(sep = "\\newpage")
sepAn optional separator to insert between each content block.
Default is a \n\\newpage\n markdown.
list() of teal_card
reset()
Resets the Reporter, removing all teal_card objects and metadata.
Reporter$reset()
self, invisibly.
remove_cards()
Removes specific teal_card objects from the Reporter by their indices.
Reporter$remove_cards(ids = NULL)
ids(integer, character) the indexes of cards (either name)
self, invisibly.
get_metadata()
Get the metadata associated with this Reporter.
Reporter$get_metadata()
named list of metadata to be appended.
reporter <- Reporter$new()$append_metadata(list(sth = "sth")) reporter$get_metadata()
append_metadata()
Appends metadata to this Reporter.
Reporter$append_metadata(meta)
meta(named list) of metadata to be appended.
self, invisibly.
reporter <- Reporter$new()$append_metadata(list(sth = "sth")) reporter$get_metadata()
from_reporter()
Reinitializes a Reporter instance by copying the report cards and metadata from another Reporter.
Reporter$from_reporter(reporter)
reporter(Reporter) instance to copy from.
invisibly self
reporter <- Reporter$new() reporter$from_reporter(reporter)
to_list()
Convert a Reporter to a list and transfer any associated files to specified directory.
Reporter$to_list(output_dir)
output_dir(character(1)) a path to the directory where files will be copied.
named list representing the Reporter instance, including version information,
metadata, and report cards.
reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "testdir") dir.create(tmp_dir) reporter$to_list(tmp_dir)
write_figures()
Extracts and saves all figure elements from the teal_card objects in the
Reporter to a specified directory.
Reporter$write_figures(output_dir, sub_directory = "figures")
output_dir(character(1)) a path to the directory where figures will be saved.
sub_directory(character(1)) a sub-directory within output_dir to save figures.
from_list()
Reinitializes a Reporter from a list representation and associated files in a specified directory.
Reporter$from_list(rlist, output_dir)
rlist(named list) representing a Reporter instance.
output_dir(character(1)) a path to the directory from which files will be copied.
self, invisibly.
reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "testdir") unlink(tmp_dir, recursive = TRUE) dir.create(tmp_dir) reporter$from_list(reporter$to_list(tmp_dir), tmp_dir)
to_jsondir()
Serializes the Reporter to a JSON file and copies any associated files to a specified directory.
Reporter$to_jsondir(output_dir)
output_dir(character(1)) a path to the directory where files will be copied, JSON and statics.
output_dir argument.
reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "jsondir") dir.create(tmp_dir) reporter$to_jsondir(tmp_dir)
from_jsondir()
Reinitializes a Reporter from a JSON file and files in a specified directory.
Reporter$from_jsondir(output_dir)
output_dir(character(1)) a path to the directory with files, JSON and statics.
self, invisibly.
reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "jsondir") dir.create(tmp_dir) unlink(list.files(tmp_dir, recursive = TRUE)) reporter$to_jsondir(tmp_dir) reporter$from_jsondir(tmp_dir)
set_id()
Set the Reporter id
Optionally add id to a Reporter which will be compared when it is rebuilt from a list.
The id is added to the downloaded file name.
Reporter$set_id(id)
id(character(1)) a Report id.
self, invisibly.
open_previewer()
Get or set the reactive trigger to open the previewer modal.
Reporter$open_previewer(val)
valvalue to the passed to the reactive trigger.
reactiveVal value
get_cached_html()
Get cached HTML for a specific teal_card by its id.
Reporter$get_cached_html(card_id)
card_id(character(1)) the unique id of the card.
get_id()
Get the Reporter id
Reporter$get_id()
character(1) the Reporter id.
set_template()
Set template function for teal_card
Set a function that is called on every report content (of class teal_card) added through $append_cards
Reporter$set_template(template)
template(function) a template function.
self, invisibly.
reporter <- teal.reporter::Reporter$new()
template_fun <- function(document) {
disclaimer <- teal.reporter::teal_card("Here comes disclaimer text")
c(disclaimer, document)
}
reporter$set_template(template_fun)
doc1 <- teal.reporter::teal_card("## Header 2 text", "Regular text")
metadata(doc1, "title") <- "Welcome card"
reporter$append_cards(doc1)
reporter$get_cards()
get_template()
Get the Reporter template
Reporter$get_template()
a template function.
clone()
The objects of this class are cloneable with this method.
Reporter$clone(deep = FALSE)
deepWhether to make a deep clone.
if Report has an id when converting to JSON then It will be compared to the currently available one.
if Report has an id when converting to JSON then It will be compared to the currently available one.
library(ggplot2) card1 <- teal_card("## Header 2 text", "A paragraph of default text") card1 <- c(card1, ggplot(iris, aes(x = Petal.Length)) + geom_histogram()) metadata(card1, "title") <- "Card1" card2 <- teal_card("Document introduction") metadata(card2, "title") <- "Card2" reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) library(rtables) # With the card1 from above lyt <- analyze(split_rows_by(basic_table(), "Day"), "Ozone", afun = mean) table_res2 <- build_table(lyt, airquality) card2 <- teal_card( "## Header 2 text", "A paragraph of default text", table_res2 ) metadata(card2, "title") <- "Card2" reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) names(reporter$get_cards()) reporter$reorder_cards(c("Card2", "Card1")) names(reporter$get_cards()) # With card1 and card2 from above metadata(reporter$get_cards()[[1]], "title") reporter$replace_card(card2, names(reporter$get_cards())[[1]]) metadata(reporter$get_cards()[[1]], "title") # With card1 and card2 from above reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) reporter$get_cards() # With card1 and card2 from above reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) reporter$get_blocks() ## ------------------------------------------------ ## Method `Reporter$new` ## ------------------------------------------------ reporter <- Reporter$new() ## ------------------------------------------------ ## Method `Reporter$get_metadata` ## ------------------------------------------------ reporter <- Reporter$new()$append_metadata(list(sth = "sth")) reporter$get_metadata() ## ------------------------------------------------ ## Method `Reporter$append_metadata` ## ------------------------------------------------ reporter <- Reporter$new()$append_metadata(list(sth = "sth")) reporter$get_metadata() ## ------------------------------------------------ ## Method `Reporter$from_reporter` ## ------------------------------------------------ reporter <- Reporter$new() reporter$from_reporter(reporter) ## ------------------------------------------------ ## Method `Reporter$to_list` ## ------------------------------------------------ reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "testdir") dir.create(tmp_dir) reporter$to_list(tmp_dir) ## ------------------------------------------------ ## Method `Reporter$from_list` ## ------------------------------------------------ reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "testdir") unlink(tmp_dir, recursive = TRUE) dir.create(tmp_dir) reporter$from_list(reporter$to_list(tmp_dir), tmp_dir) ## ------------------------------------------------ ## Method `Reporter$to_jsondir` ## ------------------------------------------------ reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "jsondir") dir.create(tmp_dir) reporter$to_jsondir(tmp_dir) ## ------------------------------------------------ ## Method `Reporter$from_jsondir` ## ------------------------------------------------ reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "jsondir") dir.create(tmp_dir) unlink(list.files(tmp_dir, recursive = TRUE)) reporter$to_jsondir(tmp_dir) reporter$from_jsondir(tmp_dir) ## ------------------------------------------------ ## Method `Reporter$set_template` ## ------------------------------------------------ reporter <- teal.reporter::Reporter$new() template_fun <- function(document) { disclaimer <- teal.reporter::teal_card("Here comes disclaimer text") c(disclaimer, document) } reporter$set_template(template_fun) doc1 <- teal.reporter::teal_card("## Header 2 text", "Regular text") metadata(doc1, "title") <- "Welcome card" reporter$append_cards(doc1) reporter$get_cards()library(ggplot2) card1 <- teal_card("## Header 2 text", "A paragraph of default text") card1 <- c(card1, ggplot(iris, aes(x = Petal.Length)) + geom_histogram()) metadata(card1, "title") <- "Card1" card2 <- teal_card("Document introduction") metadata(card2, "title") <- "Card2" reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) library(rtables) # With the card1 from above lyt <- analyze(split_rows_by(basic_table(), "Day"), "Ozone", afun = mean) table_res2 <- build_table(lyt, airquality) card2 <- teal_card( "## Header 2 text", "A paragraph of default text", table_res2 ) metadata(card2, "title") <- "Card2" reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) names(reporter$get_cards()) reporter$reorder_cards(c("Card2", "Card1")) names(reporter$get_cards()) # With card1 and card2 from above metadata(reporter$get_cards()[[1]], "title") reporter$replace_card(card2, names(reporter$get_cards())[[1]]) metadata(reporter$get_cards()[[1]], "title") # With card1 and card2 from above reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) reporter$get_cards() # With card1 and card2 from above reporter <- Reporter$new() reporter$append_cards(list(card1, card2)) reporter$get_blocks() ## ------------------------------------------------ ## Method `Reporter$new` ## ------------------------------------------------ reporter <- Reporter$new() ## ------------------------------------------------ ## Method `Reporter$get_metadata` ## ------------------------------------------------ reporter <- Reporter$new()$append_metadata(list(sth = "sth")) reporter$get_metadata() ## ------------------------------------------------ ## Method `Reporter$append_metadata` ## ------------------------------------------------ reporter <- Reporter$new()$append_metadata(list(sth = "sth")) reporter$get_metadata() ## ------------------------------------------------ ## Method `Reporter$from_reporter` ## ------------------------------------------------ reporter <- Reporter$new() reporter$from_reporter(reporter) ## ------------------------------------------------ ## Method `Reporter$to_list` ## ------------------------------------------------ reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "testdir") dir.create(tmp_dir) reporter$to_list(tmp_dir) ## ------------------------------------------------ ## Method `Reporter$from_list` ## ------------------------------------------------ reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "testdir") unlink(tmp_dir, recursive = TRUE) dir.create(tmp_dir) reporter$from_list(reporter$to_list(tmp_dir), tmp_dir) ## ------------------------------------------------ ## Method `Reporter$to_jsondir` ## ------------------------------------------------ reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "jsondir") dir.create(tmp_dir) reporter$to_jsondir(tmp_dir) ## ------------------------------------------------ ## Method `Reporter$from_jsondir` ## ------------------------------------------------ reporter <- Reporter$new() tmp_dir <- file.path(tempdir(), "jsondir") dir.create(tmp_dir) unlink(list.files(tmp_dir, recursive = TRUE)) reporter$to_jsondir(tmp_dir) reporter$from_jsondir(tmp_dir) ## ------------------------------------------------ ## Method `Reporter$set_template` ## ------------------------------------------------ reporter <- teal.reporter::Reporter$new() template_fun <- function(document) { disclaimer <- teal.reporter::teal_card("Here comes disclaimer text") c(disclaimer, document) } reporter$set_template(template_fun) doc1 <- teal.reporter::teal_card("## Header 2 text", "Regular text") metadata(doc1, "title") <- "Welcome card" reporter$append_cards(doc1) reporter$get_cards()
Provides a button that triggers showing the report preview in a modal.
For more details see the vignette: vignette("previewerReporter", "teal.reporter").
preview_report_button_ui(id, label = "Preview Report") preview_report_button_srv(id, reporter)preview_report_button_ui(id, label = "Preview Report") preview_report_button_srv(id, reporter)
id |
( |
label |
( |
reporter |
( |
NULL.
Module offers functionalities to visualize, manipulate, and interact with report cards that have been added to a report. It includes a previewer interface to see the cards and options to modify the report before downloading.
Cards are saved by the shiny bookmarking mechanism.
For more details see the vignette: vignette("previewerReporter", "teal.reporter").
This function is deprecated and will be removed in the next release.
Please use preview_report_button_ui() and preview_report_button_srv()
to create a preview button that opens a modal with the report preview.
reporter_previewer_ui(id) reporter_previewer_srv( id, reporter, global_knitr = getOption("teal.reporter.global_knitr"), rmd_output = getOption("teal.reporter.rmd_output"), rmd_yaml_args = getOption("teal.reporter.rmd_yaml_args"), previewer_buttons = c("download", "load", "reset") )reporter_previewer_ui(id) reporter_previewer_srv( id, reporter, global_knitr = getOption("teal.reporter.global_knitr"), rmd_output = getOption("teal.reporter.rmd_output"), rmd_yaml_args = getOption("teal.reporter.rmd_yaml_args"), previewer_buttons = c("download", "load", "reset") )
id |
( |
reporter |
( |
global_knitr |
( |
rmd_output |
( |
rmd_yaml_args |
( |
previewer_buttons |
( |
To access the default values for the global_knitr parameter,
use getOption('teal.reporter.global_knitr'). These defaults include:
echo = TRUE
tidy.opts = list(width.cutoff = 60)
tidy = TRUE if formatR package is installed, FALSE otherwise
NULL.
Provides a button that triggers resetting the report content.
For more information, refer to the vignette: vignette("simpleReporter", "teal.reporter").
reset_report_button_ui(id, label = NULL) reset_report_button_srv(id, reporter)reset_report_button_ui(id, label = NULL) reset_report_button_srv(id, reporter)
id |
( |
label |
( |
reporter |
( |
NULL.
rmarkdown packageRetrieves the arguments for a specified document output type from the rmarkdown package.
rmd_output_arguments(output_name, default_values = FALSE)rmd_output_arguments(output_name, default_values = FALSE)
output_name |
( |
default_values |
( |
rmd_output_arguments("pdf_document") rmd_output_arguments("pdf_document", TRUE)rmd_output_arguments("pdf_document") rmd_output_arguments("pdf_document", TRUE)
rmarkdown packageRetrieves vector of available document output types from the rmarkdown package,
such as pdf_document, html_document, etc.
rmd_outputs()rmd_outputs()
character vector.
rmd_outputs()rmd_outputs()
Module provides compact UI and server functions for managing a report in a shiny app.
This module combines functionalities for adding cards to a report,
downloading the report, and resetting report content.
For more details see the vignette: vignette("simpleReporter", "teal.reporter").
simple_reporter_ui(id) simple_reporter_srv( id, reporter, card_fun, global_knitr = getOption("teal.reporter.global_knitr"), rmd_output = getOption("teal.reporter.rmd_output"), rmd_yaml_args = getOption("teal.reporter.rmd_yaml_args") )simple_reporter_ui(id) simple_reporter_srv( id, reporter, card_fun, global_knitr = getOption("teal.reporter.global_knitr"), rmd_output = getOption("teal.reporter.rmd_output"), rmd_yaml_args = getOption("teal.reporter.rmd_yaml_args") )
id |
( |
reporter |
( |
card_fun |
( |
global_knitr |
( |
rmd_output |
( |
rmd_yaml_args |
( |
To access the default values for the global_knitr parameter,
use getOption('teal.reporter.global_knitr'). These defaults include:
echo = TRUE
tidy.opts = list(width.cutoff = 60)
tidy = TRUE if formatR package is installed, FALSE otherwise
NULL.
if (interactive()) { library(shiny) shinyApp( ui = fluidPage(simple_reporter_ui("simple")), server = function(input, output, session) { simple_reporter_srv("simple", Reporter$new(), function(card) card) } ) }if (interactive()) { library(shiny) shinyApp( ui = fluidPage(simple_reporter_ui("simple")), server = function(input, output, session) { simple_reporter_srv("simple", Reporter$new(), function(card) card) } ) }
teal_card: An S3 class for managing teal reportsThe teal_card S3 class provides functionality to store, manage, edit, and adjust report contents.
It enables users to create, manipulate, and serialize report-related data efficiently.
The teal_card() function serves two purposes:
When called with a teal_report object, it acts as a getter and returns the card slot.
When called with other arguments, it creates a new teal_card object from those arguments.
This function ensures that input is converted to a teal_card object. It accepts various input types and converts them appropriately.
teal_card(...) teal_card(x) <- value as.teal_card(x) ## S3 method for class 'teal_card' c(...) ## S3 method for class 'teal_card' x[i]teal_card(...) teal_card(x) <- value as.teal_card(x) ## S3 method for class 'teal_card' c(...) ## S3 method for class 'teal_card' x[i]
... |
Elements from which |
x |
Object to convert to teal_card |
value |
( |
i |
index specifying elements to extract or replace |
The teal_card class supports c() and x[i] methods for combining and subsetting elements.
However, these methods only function correctly when the first element is a teal_card.
An S3 list of class teal_card.
A teal_card object
code_chunk(), render(), toHTML()
# create an empty card report <- teal_card() # Create a card with content report <- teal_card( "## Headline", "This is `iris` table", code_chunk("print(iris)", lang = "R"), iris ) # Add elements to the report report <- c( report, list("## mtcars Table"), code_chunk("print(mtcars)", lang = "R"), mtcars ) # Subset the report to keep only the first two elements report[1:2] # Replace element report[[1]] <- "## Iris Table" # Append element report <- append(report, teal_card("# Awesome Report"), after = 0) tools::toHTML(report) if (interactive()) { render(report, output_format = rmarkdown::pdf_document()) }# create an empty card report <- teal_card() # Create a card with content report <- teal_card( "## Headline", "This is `iris` table", code_chunk("print(iris)", lang = "R"), iris ) # Add elements to the report report <- c( report, list("## mtcars Table"), code_chunk("print(mtcars)", lang = "R"), mtcars ) # Subset the report to keep only the first two elements report[1:2] # Replace element report[[1]] <- "## Iris Table" # Append element report <- append(report, teal_card("# Awesome Report"), after = 0) tools::toHTML(report) if (interactive()) { render(report, output_format = rmarkdown::pdf_document()) }
teal applicationsInitializes a reportable data for teal application.
teal_report( ..., teal_card = NULL, code = character(0), join_keys = teal.data::join_keys() ) as.teal_report(x)teal_report( ..., teal_card = NULL, code = character(0), join_keys = teal.data::join_keys() ) as.teal_report(x)
... |
any number of objects (presumably data objects) provided as |
teal_card |
( |
code |
( Use |
join_keys |
( |
x |
( |
A teal_report object.
# Initialize teal_report with existing h2 header report <- teal_report(teal_card = teal_card("## Analysis Report")) # Use within() to execute code and add code-chunk report <- within(report, { data <- iris summary_stats <- summary(data) }) # Access objects created within the report report$data report$summary_stats # within() automatically captures code and outputs report <- within(report, { head(iris) }) # Add arbitrary markdown content to the card teal_card(report) <- c( teal_card(report), teal_card("### Conclusion", "The analysis is complete.") ) # View the generated card with code chunks teal_card(report) # View report in HTML format tools::toHTML(report) if (interactive()) { # Render the report to various formats render(report, output_format = rmarkdown::html_document()) render(report, output_format = rmarkdown::pdf_document()) }# Initialize teal_report with existing h2 header report <- teal_report(teal_card = teal_card("## Analysis Report")) # Use within() to execute code and add code-chunk report <- within(report, { data <- iris summary_stats <- summary(data) }) # Access objects created within the report report$data report$summary_stats # within() automatically captures code and outputs report <- within(report, { head(iris) }) # Add arbitrary markdown content to the card teal_card(report) <- c( teal_card(report), teal_card("### Conclusion", "The analysis is complete.") ) # View the generated card with code chunks teal_card(report) # View report in HTML format tools::toHTML(report) if (interactive()) { # Render the report to various formats render(report, output_format = rmarkdown::html_document()) render(report, output_format = rmarkdown::pdf_document()) }
ReporterCard/teal_card content to rmarkdown
This is an S3 generic that is used to generate content in rmarkdown format
from various types of blocks in a ReporterCard or teal_card object.
to_rmd(block, ...)to_rmd(block, ...)
block |
( |
... |
additional arguments passed to implemented methods for different classes. |
to_rmd
The methods for this S3 generic can be extended by the app developer or even overwritten.
For this a function with the name to_rmd.<class> should be defined in the
Global Environment or registered as an S3 method, where <class> is the class of the
object to be converted.
For example, to override the default behavior for code_chunk class, you can use:
to_rmd.code_chunk <- function(block, ...) {
# custom implementation
sprintf("### A custom code chunk\n\n```{r}\n%s\n```\n", block)
}
Alternatively, the S3 method can be registered using registerS3method("to_rmd", "<class>", fun)
teal.reporter provides default to_rmd methods for several common classes that
returns the content in appropriate R Markdown syntax.
These include:
character
code_chunk() objects
ggplot2 plots
data.frame
flextable
rtables tables
and others.
All of these defaults can be overridden by defining new to_rmd.<class> methods.
These methods are implemented internally using the helper function .to_rmd.<class>.
character(1) containing a content or Rmarkdown document.
to_rmd(c("## This is a simple text block.", "", "With a paragraph break.")) to_rmd(code_chunk("summary(cars)")) to_rmd(data.frame(x = 1:10, y = 21:30), folder_path = tempdir()) # Example with ggplot2 will create a temporary RDS file in the tempdir() to_rmd( ggplot2::ggplot(mtcars, ggplot2::aes(x = wt, y = mpg)) + ggplot2::geom_point(), folder_path = tempdir() # internal argument of ggplot2 method )to_rmd(c("## This is a simple text block.", "", "With a paragraph break.")) to_rmd(code_chunk("summary(cars)")) to_rmd(data.frame(x = 1:10, y = 21:30), folder_path = tempdir()) # Example with ggplot2 will create a temporary RDS file in the tempdir() to_rmd( ggplot2::ggplot(mtcars, ggplot2::aes(x = wt, y = mpg)) + ggplot2::geom_point(), folder_path = tempdir() # internal argument of ggplot2 method )
The toHTML S3 generic method converts various report objects into HTML representations.
This is the primary method for rendering report content for display in web browsers,
IDE Viewer, or for inclusion in Shiny applications.
## Default S3 method: toHTML(x, ...)## Default S3 method: toHTML(x, ...)
x |
The object to convert to HTML. Supported types include:
|
... |
Additional arguments passed to methods. |
teal_card
The teal_card class is a central component in the teal.reporter ecosystem. It is an S3 list
where each element represents a piece of report content (text, plots, tables, code chunks, etc.).
The toHTML method for teal_card objects:
Iterates through each element in the teal_card list
Calls toHTML() recursively on each element based on its class
Wraps all converted elements in a bslib::card() container
This hierarchical conversion allows complex report structures to be rendered as styled HTML with proper formatting for each content type.
Text and Markdown: Character strings are converted to HTML using CommonMark markdown syntax.
Supports headers, lists, code blocks, emphasis, and other markdown features.
Code Chunks: Created with code_chunk(), these are rendered as collapsible Bootstrap
accordions with syntax highlighting. The accordion includes the programming language indicator
and an icon.
Plots: Plot objects (ggplot, recordedplot, trellis, grob) are converted to PNG
images with base64-encoded data URIs, making them self-contained in the HTML output.
Tables: Table objects are converted to styled HTML tables, typically via flextable
for consistent formatting.
All HTML output is wrapped with htmltools::browsable(), which enables:
Automatic render in IDE Viewer when displayed interactively
Proper HTML dependency injection (Bootstrap CSS/JavaScript, Font Awesome icons, etc.)
Standalone HTML files with all required resources
You can override the browsable behavior with:
print(toHTML(x), browse = FALSE) # Print markup to console instead
An HTML representation of the input object. The exact return type depends on the input class:
For teal_card: A bslib::card() containing all elements
For code_chunk: A bslib::accordion() with the code
For plots: A shiny::tags$img() tag
For text: HTML markup from markdown conversion
For tables: HTML table elements
All returns are wrapped with htmltools::browsable() to enable viewer display.
teal_report() for creating report objects
teal_card() for creating report cards
code_chunk() for creating code blocks
render() for rendering complete reports to files
# Initialize empty report report <- teal_report() # Add arbitrary markdown elements to the report's teal_card teal_card(report) <- c( teal_card(report), "## Document section", "Lorem ipsum dolor sit amet" ) # Use within() to execute code and add code-chunk report <- within(report, a <- 2) # within() automatically captures code and outputs report <- within(report, plot(a)) html <- tools::toHTML(report) # display HTML markup in viewer html # Print HTML markup to console instead of viewer print(html, browse = FALSE)# Initialize empty report report <- teal_report() # Add arbitrary markdown elements to the report's teal_card teal_card(report) <- c( teal_card(report), "## Document section", "Lorem ipsum dolor sit amet" ) # Use within() to execute code and add code-chunk report <- within(report, a <- 2) # within() automatically captures code and outputs report <- within(report, plot(a)) html <- tools::toHTML(report) # display HTML markup in viewer html # Print HTML markup to console instead of viewer print(html, browse = FALSE)
These functions provide a user interface and server logic for editing and extending the editor functionality to support new data types.
ui_editor_block(id, value, ...) srv_editor_block(id, value, ...)ui_editor_block(id, value, ...) srv_editor_block(id, value, ...)
id |
( |
value |
The content of the block to be edited. It can be a character string or other types. |
... |
Additional arguments passed to dispatch functions. |
The methods for this S3 generic can be extended by the app developer to new classes
or even overwritten.
For this a function with the name srv_editor_block.<class> and/or ui_editor_block.<class>
should be defined in the Global Environment, where <class> is the class of
the object to be used in the method.
For example, to override the default behavior for character class, you can use:
ui_editor_block.character <- function(id, value) {
# custom implementation
shiny::tagList(
shiny::tags$h6(shiny::icon("pencil", class = "text-muted"), "Editable CUSTOM markdown block"),
shiny::textAreaInput(ns("content"), label = NULL, value = value, width = "100%")
)
}
srv_editor_block.character <- function(id, value) {
# custom implementation
# ...
}
Alternatively, you can register the S3 method using
registerS3method("ui_editor_block", "<class>", fun) and
registerS3method("srv_editor_block", "<class>", fun).
ui_editor_block
cached_html: (shiny.tag or shiny.tag.list) Cached HTML content to display in the UI that is
rendered at the time the card is being added. Default is NULL.
teal will call on ui_editor_block with the contents of each element
of the card (value argument) and an optional parameter cached_html.
This parameter is not part of the S3 generic as it is optional when overriding the method.
The usage of this argument improve the UI performance by avoiding re-rendering on the fly. When overriding this method, the usage of this argument is optional, hence it is not part of the S3 generic.