Replies: 4 comments 5 replies
-
A Lua filter could avoid the repetition but I just though of the following workaround. ---
title: "Quarto Playground"
format: html
params:
pca: true
execute:
echo: false
---
::: {.content-hidden}
### Principal Component Analysis (PCA)
:::
```{r}
#| eval: !expr isTRUE(params[["pca"]])
#| output: asis
cat("\n\n#### Principal Component Analysis (PCA)\n\n")
```
```{r}
#| eval: !expr isTRUE(params[["pca"]])
plot(1)
``` |
Beta Was this translation helpful? Give feedback.
-
This works with the behaviour I intended, but I cannot express enough how practical would be that there's a conditional evaluation at the level of the shortcode, not only for avoiding redundancy (expliciting twice the eval and hiding the title), but because it would be compatible with other shortcodes and for example, I could do a .{panel-tabset} that shows only the panels that were evaluated. I think one of the strengths of Quarto is the use of shortcodes, which are compatible with the visual editor too, and the amazing things that could be done with a conditional-evaluation, not only a .content-hidden, would be awesome. I'll try, when I have more time, to implement my own lua filter. |
Beta Was this translation helpful? Give feedback.
-
I second @joanbadia's request. If the existing shortcode would be enhanced to support |
Beta Was this translation helpful? Give feedback.
-
Thanks @mcanouil for the clarification and sorry for using the wrong terminology. I know that I'd like to declare a metadata entry, e.g. "customer". In a document with say 95% of content valid for all customers, 5% is customer specific. Instead of defining a metadata entry for each customer, I'd like to assign the customer value when rendering the document (e. g. with Hence my suggestion to enhance the existing conditional This use case might be slightly different from that of the OP but I think it also might serve him. And I'm aware that only parameters can be used for R code chunks. |
Beta Was this translation helpful? Give feedback.
-
Description
I want to do parametrised analyses modules, which would be conditionally evaluated affecting both titles and chunks, so that the titles aren't printed on the output but are still on the .qmd file for navigation purposes.
I have already tried the combination of
:::{.content-hidden when-meta="params.pca"}
&{r} #| eval: !expr !expr params$pca
without success, specially when working with{{< includes ... >}}
.The following option also is not what I want because it'll make the title not available for navigation:
Now I am trying to create my own shortcode or lua filter that achieves this purpose.
This is currently my first attempt, any help it'll be welcome:
conditional-evaluation.lua
analysis.qmd
module-dimred.qmd
Beta Was this translation helpful? Give feedback.
All reactions