rk.JS.header: Generate JavaScript header object

View source: R/rk.JS.header.R

rk.JS.headerR Documentation

Generate JavaScript header object

Description

Generate JavaScript header object

Usage

rk.JS.header(title, ..., level = NULL, guess.getter = FALSE, .add = list())

Arguments

title

Either a character string or object of class rk.JS.i18n. Will become the header title, nested in an i18n() call.

...

An optional number of additional info to add to the header. Each entry must be named add or addFromUI – note that you can use multiple entries with the same name here. Entries named add must be vectors of legth 2, the first being the caption (character), the second its value (either character, a XiMpLe node from the dialog or a single rk.JS.ite object); if the second value is named noquote or nq, the JS output will be nested inside noquote(). rk.JS.ite objects will be printed in a condensed format. Entries named addFromUI must have exactly one value specifying the GUI element to query (either character or a XiMpLe node from the dialog).

level

Integer, if not NULL will be added as the header level.

guess.getter

Locigal, if TRUE try to get a good default getter function for JavaScript variable values.

.add

Same as ..., but provided as a single list. If used, values will be appended to ....

Value

A character string.

Examples

my.cbox <- rk.XML.cbox("This is a test")
rk.JS.header("Test results", addFromUI=my.cbox)

# let's assume we create an R object called "results"
# in the plugin dialog, this is how you could fetch
# portions of it to be added as a parameter in the output
rk.JS.header(
  "Test results",
  add=c("Significance level", noquote="results[[\\\"alpha\\\"]]")
)

# a dummy example using an rk.JS.ite object made with js()
rk.JS.header(
  "Test results",
  add=c(
    "Significance level",
    js(
      if(my.cbox){
        "this"
      } else {
        "that"
      },
      keep.ite=TRUE
    )
  )
)

rkward-community/rkwarddev documentation built on May 9, 2022, 3:02 p.m.