Skip to content

Commit

Permalink
CTUtemplate 0.6.1
Browse files Browse the repository at this point in the history
---------------------
addition of use_qmd_typst
  • Loading branch information
aghaynes committed Feb 27, 2025
1 parent 3152c9f commit db820ec
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Package: CTUtemplate
Title: Example RStudio Project Templates
Author: Alan G. Haynes
Maintainer: Alan G. Haynes <[email protected]>
Version: 0.6.0
Version: 0.6.1
Description: Templates and functions for use in CTU Bern.
Depends:
R (>= 3.3.2)
License: GPL (>= 2)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Imports:
bookdown,
fs,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(use_qmd_html)
export(use_qmd_htmlrecruitment)
export(use_qmd_htmlsampsi)
export(use_qmd_pres)
export(use_qmd_typst)
export(use_quarto)
export(use_recreport_template)
export(use_report_template)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
CTUtemplate 0.6.1
---------------------
addition of use_qmd_typst

CTUtemplate 0.6.0
---------------------
update templates to use DCR-like branding
Expand Down
24 changes: 23 additions & 1 deletion R/use_.R
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,27 @@ use_qmd_htmlsampsi <- function(save_in = ".", open = TRUE){

}

#' Use the CTU quarto typst template
#' This function will download and optionally open the quarto markdown (qmd) file
#' and the other necessary files from github.
#' @describeIn use_qmd Sample Size Report Template
#' @param save_in directory to save the main qmd in
#' @param open logical indicating whether to open the file
#' @export
#' @examples
#' # dir <- tempdir()
#' # file <- file.path(dir, "filename.qmd")
#' # use_qmd_html(file, FALSE)
#' # in practice at CTU:
#' # use_qmd_typst("08_Reports_xx/ReportName.qmd", TRUE)
use_qmd_typst <- function(save_in = ".", open = TRUE){

if_no_ping_stop()

use_quarto("typst", save_in, open = open)

}



#' Get a quarto template from the CTU-Bern quarto repository
Expand All @@ -297,14 +318,15 @@ use_qmd_htmlsampsi <- function(save_in = ".", open = TRUE){
#' #use_quarto("html", ".")
use_quarto <- function(x, dir, open = TRUE){

if(!x %in% c("html", "html-ss", "html-rec", "pres")){
if(!x %in% c("html", "html-ss", "html-rec", "pres", "typst")){
stop("unknown branch of CTU-Bern/quarto")
}

wd <- getwd()
on.exit(setwd(wd))

setwd(dir)
if(length(list.files()) > 0) stop("'dir' is not empty - an empty 'dir' is necessary")

system(glue("quarto use template CTU-Bern/quarto@{x} --no-prompt"))

Expand Down
14 changes: 14 additions & 0 deletions man/use_qmd.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit db820ec

Please sign in to comment.