Debian Codegraph @

inst/app_template/app.R

raw
1 ui <- fluidPage(
2 {{
3 # These blocks of code are processed with htmlTemplate()
4 if (isTRUE(module)) {
5 ' # ======== Modules ========
6 # exampleModuleUI is defined in R/example-module.R
7 wellPanel(
8 h2("Modules example"),
9 exampleModuleUI("examplemodule1", "Click counter #1"),
10 exampleModuleUI("examplemodule2", "Click counter #2")
11 ),
12 # =========================
13 '
14 }
15 }}
16 wellPanel(
17 h2("Sorting example"),
18 sliderInput("size", "Data size", min = 5, max = 20, value = 10),
19 {{
20 if (isTRUE(rdir)) {
21 ' div("Lexically sorted sequence:"),'
22 } else {
23 ' div("Sorted sequence:"),'
24 }
25 }}
26 verbatimTextOutput("sequence")
27 )
28 )
29
30 server <- function(input, output, session) {
31 {{
32 if (isTRUE(module)) {
33 ' # ======== Modules ========
34 # exampleModuleServer is defined in R/example-module.R
35 exampleModuleServer("examplemodule1")
36 exampleModuleServer("examplemodule2")
37 # =========================
38 '
39 }
40 }}
41 data <- reactive({
42 {{
43 if (isTRUE(rdir)) {
44 ' # lexical_sort from R/example.R
45 lexical_sort(seq_len(input$size))'
46 } else {
47 ' sort(seq_len(input$size))'
48 }
49 }}
50 })
51 output$sequence <- renderText({
52 paste(data(), collapse = " ")
53 })
54 }
55
56 shinyApp(ui, server)