Skip to contents

This function inserts a template for a surveydown page at the current cursor position in the active RStudio document. It provides a basic structure for a new page, including a title, content area, and a next button. If the function call exists in the document, it will be removed before inserting the template.

Usage

sd_add_page()

Value

This function does not return a value. It modifies the active document as a side effect by inserting text and potentially removing a function call.

Details

IMPORTANT: This function should be run outside any division or R code chunk in your 'Quarto' document. Running it inside a division or code chunk may result in an incorrect page structure.

The function performs the following steps:

  1. Checks for and removes any existing sd_add_page() function call in the document.

  2. Inserts a template at the current cursor position.

The template includes:

  • A div with class 'sd-page' and a placeholder page ID

  • A placeholder for the page title

  • A placeholder for page contents

  • An R code chunk with a placeholder for questions and a next button

Examples

if (interactive()) {
  library(surveydown)

  # Insert a new page template
  sd_add_page()
}