Skip to content

Commit faa4422

Browse files
committed
Simplify html generation in Interface example
1 parent c296c71 commit faa4422

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

R/examples.R

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,34 @@ interfaceExample <- function(jaspResults, dataset, options) {
33
jaspResults[["explanation"]] <- createJaspHtml(title = "Outputs as html",
44
text = "Here we show the options as they are understood by the R backend.")
55

6-
# We'll build the output string by appending information to an initially empty container
7-
aux <- ""
8-
96
jaspResults[["logicals"]] <- createJaspHtml(
107
title = "Logical controls",
11-
text = aux |>
12-
paste(gettextf("The tick mark is set to: %s", as.character(options$my_tick_mark))) |>
13-
paste(gettextf("<br> The radio buttons are set to: %s", as.character(options$radio_buttons)))
8+
text = sprintf("The tick mark is set to: %s
9+
The radio buttons are set to: %s",
10+
as.character(options$my_tick_mark),
11+
as.character(options$radio_buttons))
1412
)
1513

1614
jaspResults[["others"]] <- createJaspHtml(
1715
title = "Other controls",
18-
text = aux |>
19-
paste(gettextf("The chosen dropdown element is: %s", as.character(options$my_dropdown))) |>
20-
paste(gettextf("<br> The slider value is: %s", as.character(options$my_slider)))
16+
text = sprintf("The chosen dropdown element is: %s
17+
The slider value is: %s",
18+
as.character(options$my_dropdown),
19+
as.character(options$my_slider))
2120
)
2221

2322
jaspResults[["keyboard"]] <- createJaspHtml(
2423
title = "Keyboard controls",
25-
text = aux |>
26-
paste(gettextf("The integer is set to: %s", as.character(options$my_integer), sep = "")) |>
27-
paste(gettextf("<br> The double is set to: %s", as.character(options$my_double), sep = ". ")) |>
28-
paste(gettextf("<br> The percentage is set to: %s", as.character(options$my_percent), sep = ". ")) |>
29-
paste(gettextf("<br> The confidence interval is set to: %s", as.character(options$my_ci), sep = ". ")) |>
30-
paste(gettextf("<br> The text box is set to: <i>%s</i>", options$my_text, sep = ". "))
24+
text = sprintf("The integer is set to: %s
25+
The double is set to: %s
26+
The percentage is set to: %s
27+
The confidence interval is set to: %s
28+
The text box is set to: <i>%s</i>",
29+
as.character(options$my_integer),
30+
as.character(options$my_double),
31+
as.character(options$my_percent),
32+
as.character(options$my_ci),
33+
options$my_text)
3134
)
3235

3336
return()

0 commit comments

Comments
 (0)