rich-iannone / DiagrammeR
Showing 2 of 5 files from the diff.
Other files ignored by Codecov
NEWS.md has changed.
man/grViz.Rd has changed.

@@ -14,6 +14,7 @@
Loading
14 14
#'   graphic in pixels.
15 15
#' @param height An optional parameter for specifying the height of the
16 16
#'   resulting graphic in pixels.
17 +
#' @param envir The environment in which substitution functionality takes place.
17 18
#'
18 19
#' @return An object of class `htmlwidget` that will intelligently print itself
19 20
#'   into HTML in a variety of contexts including the R console, within R
@@ -25,7 +26,8 @@
Loading
25 26
                  allow_subst = TRUE,
26 27
                  options = NULL,
27 28
                  width = NULL,
28 -
                  height = NULL) {
29 +
                  height = NULL,
30 +
                  envir = parent.frame()) {
29 31
30 32
  # Check for a connection or file
31 33
  if (inherits(diagram, "connection") ||
@@ -45,7 +47,7 @@
Loading
45 47
  }
46 48
47 49
  if (allow_subst == TRUE) {
48 -
    diagram <- replace_in_spec(diagram)
50 +
    diagram <- replace_in_spec(diagram, envir = envir)
49 51
  }
50 52
51 53
  # Single quotes within a diagram spec are problematic

@@ -3,6 +3,7 @@
Loading
3 3
#' Use Razor-like syntax to define a template for use in a `grViz` diagram.
4 4
#'
5 5
#' @param spec String spec to be parsed and evaluated.
6 +
#' @inheritParams grViz
6 7
#' @examples
7 8
#' \dontrun{
8 9
#' # a simple example to use a LETTER as a node label
@@ -37,7 +38,7 @@
Loading
37 38
#' }
38 39
#'
39 40
#' @export
40 -
replace_in_spec <- function(spec) {
41 +
replace_in_spec <- function(spec, envir = parent.frame()) {
41 42
42 43
  # Directive for marking subscripted text in a label or tooltip '@_'
43 44
  if (grepl("@_", spec)) {
@@ -95,7 +96,7 @@
Loading
95 96
      eval_expressions <-
96 97
        c(
97 98
          eval_expressions,
98 -
          list(eval(parse(text = split_references[i])))
99 +
          list(eval(parse(text = split_references[i]), envir = envir))
99 100
        )
100 101
    }
101 102
Files Coverage
R 81.04%
Project Totals (241 files) 81.04%