Skip to content

Instantly share code, notes, and snippets.

@baptiste
Forked from daranzolin/child.qmd
Created February 9, 2023 02:48
Show Gist options
  • Select an option

  • Save baptiste/ddd8fe83f9413001bb96e56178181dff to your computer and use it in GitHub Desktop.

Select an option

Save baptiste/ddd8fe83f9413001bb96e56178181dff to your computer and use it in GitHub Desktop.

Revisions

  1. baptiste revised this gist Feb 9, 2023. 2 changed files with 12 additions and 7 deletions.
    7 changes: 4 additions & 3 deletions child.qmd
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,11 @@

    ```{r}
    path <- fs::path("mtcars", ext = "csv")
    cmd <- paste0("{{< downloadthis ", "'", path, "'", ' dname=Mtcars label="Download the mtcars data" icon=database-fill-down type=info class=data-button id=mtcars >}}')
    path <- fs::path("<<variable>>", ext = "csv")
    cmd <- paste0("{{< downloadthis ", "'", path, "'", ' dname=<<variable>> label="Download the <<variable>> data" icon=database-fill-down type=info class=data-button id=<<variable>> >}}')
    ```


    ```{r}
    #| results: asis
    cat(cmd)
    ```
    ```
    12 changes: 8 additions & 4 deletions template.qmd
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,18 @@
    ---
    title: "template"
    title: "testchild.qmd"
    format: html
    extension: downloadthis
    ---

    ## Quarto

    Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.


    ```{r}
    #| results = "asis"
    src = knitr::knit_expand('child.qmd')
    variable <- 'dudewhereismy'
    src = knitr::knit_expand("child.qmd", delim = c("<<", ">>"))
    res = knitr::knit_child(text = unlist(src), quiet = TRUE)
    cat(res, sep = '\n')
    ```

  2. @daranzolin daranzolin created this gist Feb 9, 2023.
    10 changes: 10 additions & 0 deletions child.qmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@

    ```{r}
    path <- fs::path("mtcars", ext = "csv")
    cmd <- paste0("{{< downloadthis ", "'", path, "'", ' dname=Mtcars label="Download the mtcars data" icon=database-fill-down type=info class=data-button id=mtcars >}}')
    ```

    ```{r}
    #| results: asis
    cat(cmd)
    ```
    14 changes: 14 additions & 0 deletions template.qmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    ---
    title: "template"
    format: html
    ---


    ```{r}
    #| results = "asis"
    src = knitr::knit_expand('child.qmd')
    res = knitr::knit_child(text = unlist(src), quiet = TRUE)
    cat(res, sep = '\n')
    ```