Skip to content
Snippets Groups Projects
Commit 9f76a916 authored by arsenij.ustjanzew's avatar arsenij.ustjanzew
Browse files

fixed: render only if statical mode is used;

fixed: "title" and "author" slots are written with quotation marks in the yaml header;
changed the check if the file slot is empty in the i2dashboard object.
parent bfbf631c
No related branches found
No related tags found
2 merge requests!8Vignette: i2dash introduction,!4Filename fix
Pipeline #113497 passed
......@@ -4,7 +4,7 @@
#' @param pages A string or vector with the names of pages, which should be assembled to a report.
#' @param file The output filename (recommend that the suffix should be '.Rmd'). This file will be saved in the working directory.
#' @param exclude A string or vector with the names of pages, which should be excluded from report assembly.
#' @param render A logical indicating whether the assembled report should immediately be rendered with \code{rmarkdown::render}.
#' @param render A logical indicating whether the assembled report should immediately be rendered with \code{rmarkdown::render} (only if \code{interactive = FALSE}).
#' @param ... Additional arguments passed on to \code{rmarkdown::render}.
#'
#' @rdname i2dashboard-methods
......@@ -22,8 +22,8 @@ setMethod("assemble", "i2dashboard", function(dashboard, pages = names(dashboard
# Add YAML header
knitr::knit_expand(file = system.file("templates", "yaml_header.Rmd", package = "i2dash"),
delim = c("<%", "%>"),
title = dashboard@title,
author = dashboard@author,
title = paste0('"',dashboard@title,'"'),
author = paste0('"',dashboard@author,'"'),
theme = dashboard@theme,
interactive = dashboard@interactive) %>%
cat(file = tmp_document, append = FALSE, sep = "\n")
......@@ -71,10 +71,10 @@ setMethod("assemble", "i2dashboard", function(dashboard, pages = names(dashboard
file.copy(from = tmp_document, to = file, overwrite = TRUE)
# Render, if requested
if(dashboard@interactive) render <- FALSE # Only render, if the statical mode is used
if(render) {
rmarkdown::render(file, ...)
}
invisible(dashboard)
})
......
......@@ -45,7 +45,7 @@ setMethod("initialize", "i2dashboard", function(.Object, ...) {
.Object <- callNextMethod()
# Create nice filename from title
if(is.null(.Object@file) & !is.null(.Object@title)) {
if(length(.Object@file) == 0 & length(.Object@title) > 0) {
.Object@title %>% tolower %>% gsub(pattern = " ", replacement = "-") %>% gsub(pattern = '[^a-zA-Z0-9-]', replacement = '') %>% paste0(".Rmd") -> .Object@file
}
......
......@@ -33,7 +33,7 @@
\item{exclude}{A string or vector with the names of pages, which should be excluded from report assembly.}
\item{render}{A logical indicating whether the assembled report should immediately be rendered with \code{rmarkdown::render}.}
\item{render}{A logical indicating whether the assembled report should immediately be rendered with \code{rmarkdown::render} (only if \code{interactive = FALSE}).}
\item{...}{Additional arguments passed on to \code{rmarkdown::render}.}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment