rk.paste.JS: Paste JavaScript objects and character strings

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

rk.paste.JSR Documentation

Paste JavaScript objects and character strings

Description

Paste JavaScript objects and character strings

Usage

rk.paste.JS(
  ...,
  level = 2,
  indent.by = rk.get.indent(),
  funct = NULL,
  array = NULL,
  var.prefix = NULL,
  modifiers = NULL,
  default = NULL,
  join = NULL,
  getter = NULL,
  var = TRUE,
  empty.e = rk.get.empty.e(),
  opt.sep = NULL
)

Arguments

...

Objects of class rk.JS.ite, rk.JS.arr, rk.JS.opt, rk.JS.oset or character. Another special case is XiMpLe nodes created by rk.comment(), which will be turned into JavaScript comments (i.e., lines starting with "//").

level

Integer, which indentation level to use, minimum is 1.

indent.by

A character string defining the indentation string to use.

funct

For rk.JS.arr and rk.JS.opt objects only: Character string, name of the R function to be called to combine the options, e.g. "list" for list(), or "c" for c().

array

For rk.JS.opt objects only: Logical, whether the options should be collected in an array or a concatenated character string.

var.prefix

For rk.JS.var objects only: A character string. will be used as a prefix for the JS variable names.

modifiers

For rk.JS.var objects only: A character vector with modifiers you'd like to apply the XML node's property.

default

For rk.JS.var objects only: Logical, if TRUE the default value (no special modifier) of the node will also be defined. Does nothing if modifiers=NULL.

join

For rk.JS.var objects only: A character string, useful for GUI elements which accept multiple objects (e.g., multi-varslots). If join is something other than "", these objects will be collapsed into one string when pasted, joined by this string.

getter

For rk.JS.var objects only: A character string, naming the JavaScript function which should be used to get the values in the actual plugin. Depending on the XML element, "getString", "getBool" or "getList" can be useful alternatives. For backwards compatibility, the default is set to "getValue".

var

For rk.JS.var objects only: Logical, if FALSE the variable(s) are assumed to already be defined (globally?) and the JS keyword "var" will be omitted.

empty.e

For rk.JS.ite objects only: Logical, if TRUE will force to add empty else {} brackets when there is no else statement defined, which is considered to enhance code readability by some.

opt.sep

For rk.JS.arr and rk.JS.opt objects only: Character string, will be printed in the resulting R code before the option name.

Value

A character string.

Note

To get a list of the implemented modifiers in this package see modifiers.

See Also

rk.JS.array, rk.JS.options, rk.JS.optionset, rk.JS.vars, ite, modifiers, and the Introduction to Writing Plugins for RKWard


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