Skip to contents

Adds a textual output based on the current state of input elements.

Usage

output_text(text, tag = "p", id = NULL, class = NULL, condition = NULL)

Arguments

text

A vector of text to be parsed; see details.

tag

Tag name of the element containing the text.

id

Unique ID of the output element.

class

Class names to add to the output's element.

condition

A conditional statement to decide visibility of the entire output element.

Value

A character vector of the containing element of the text.

Details

Input References

text can include references to inputs by ID within curly brackets (e.g., "{input_id}").

Conditions

Multiple entries in text translate to separate elements. Each entry can be conditioned on a statement within curly brackets following an initial question mark (e.g., "?{input_a != 1}Input A is not 1"). If no statement is included after the question mark, the entry will be conditioned on a referred to input (TRUE if anything is selected).

Buttons

Embedded reset buttons can be specified within square brackets (e.g., "Reset[r input_id]"). Text before the brackets will be the button's display text, with multiple words included within parentheses (e.g., "(Reset Input A)[r input_a]"). If the text is a reference, this will be the default reset reference (e.g., "{input_a}[r]" is the same as "{input_a}[r input_a]").

Examples

# text that shows the current value of `input_a`, and resets it on click
output_text("Selection: {input_a}[r]")
#> [1] "<p data-autoType=\"text\" id=\"text\" class=\"auto-output output-text\"></p>"

# adds a parenthetical if the value of the input is 0
output_text(c("Selection: {input_a}[r]", "?{input_a == 0}(input is zero)"))
#> [1] "<p data-autoType=\"text\" id=\"text\" class=\"auto-output output-text\"></p>"