module_info: Obtain the module information

View source: R/modules.R

module_infoR Documentation

Obtain the module information

Description

Obtain the module information

Usage

module_info(root_path = template_root(), settings_file = "modules.yaml")

load_module(
  root_path = template_root(),
  request = list(QUERY_STRING = "/"),
  env = parent.frame()
)

Arguments

root_path

the root path of the website project

settings_file

the settings file containing the module information

request

'HTTP' request string

env

environment to load module variables into

Details

The module files are stored in modules/ folder in your project. The folder names are the module id. Within each folder, there should be one "server.R", R/, and a "module-ui.html".

The R/ folder stores R code files that generate variables, which will be available to the other two files. These variables, along with some built-ins, will be used to render "module-ui.html". The built-in functions are

ns

shiny name-space function; should be used to generate the id for inputs and outputs. This strategy avoids conflict id effectively.

.module_id

a variable of the module id

module_title

a function that returns the module label

The "server.R" has access to all the code in R/ as well. Therefore it is highly recommended that you write each 'UI' component side-by-side with their corresponding server functions and call these server functions in "server.R".

Value

A data frame with the following columns that contain the module information:

id

module id, folder name

order

display order in side-bar

group

group menu name if applicable, otherwise NA

label

the readable label to be displayed on the side-bar

icon

icon that will be displayed ahead of label, will be passed to as_icon

badge

badge text that will be displayed following the module label, will be passed to as_badge

url

the relative 'URL' address of the module.

Examples


library(shiny)
module_info()

# load master module
load_module()

# load specific module
module_data <- load_module(
  request = list(QUERY_STRING = "/?module=module_id"))
env <- module_data$environment

if(interactive()){

# get module title
env$module_title()

# generate module-specific shiny id
env$ns("input1")

# generate part of the UI
env$ui()

}


shidashi documentation built on June 21, 2022, 5:05 p.m.