Skip to contents

This function renders a Quarto .qmd document to a specified output format and then moves the resulting file to a designated output path. It uses quarto::quarto_render to perform the rendering and fs::file_move to handle the file movement.

Usage

render_qmd(input_file, output_file, output_path, file_ext, ...)

Arguments

input_file

A character string specifying the path to the input Quarto .qmd file.

output_path

A character string specifying the directory where the rendered file should be moved.

...

Additional arguments passed to quarto::quarto_render.

Value

This function does not return a value. It performs rendering and file moving operations, and displays a message indicating the file movement.

Examples

# \donttest{
# Create a simple example Quarto document
qmd_content <- '
---
title: "Test Report"
format: html
params:
  file_date: "2025-01-01"
---

# Example Report

Analysis date: `r params$file_date`
'

# Write temporary .qmd file
temp_qmd <- file.path(tempdir(), "example_report.qmd")
writeLines(qmd_content, temp_qmd)

# Render the report
render_qmd(
  input_file = temp_qmd,
  output_file = "rendered_example_report",
  file_ext = "html",
  output_path = tempdir(),
  execute_params = list(`file-date` = "2025-01-01")
)
#> pandoc 
#>   to: html
#>   output-file: rendered_example_report.html
#>   standalone: true
#>   section-divs: true
#>   html-math-method: mathjax
#>   wrap: none
#>   default-image-extension: png
#>   
#> metadata
#>   document-css: false
#>   link-citations: true
#>   date-format: long
#>   lang: en
#>   title: Test Report
#>   output-file: rendered_example_report.html
#>   
#> Output created: rendered_example_report.html
#> 
#> 
#> Error: [ENOENT] Failed to copy 'rendered_example_report.html' to '/tmp/RtmpU8txnb/rendered_example_report.html': no such file or directory

# Check output
list.files(tempdir(), pattern = "rendered_example", full.names = TRUE)
#> [1] "/tmp/RtmpU8txnb/rendered_example_report.html"
# }