yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.37k stars 874 forks source link

Add a conditional helper for checking quarto profile value #2216

Open cderv opened 1 year ago

cderv commented 1 year ago

For quarto document, some conditional content can be made on profile value. When a profile is activated QUARTO_PROFILE env var is set. https://quarto.org/docs/projects/profiles.html#overview

It would be interesting to have a helper function like for output format (is_html_output()) to test profile value

This would allow conditional chunk based on quarto profile value.

It is easy to do eval = Sys.getenv("QUARTO_PROFILE") == "profile name" but we could offer a nice shorter version.

We could either have a is_profile("profile name") that would be true on specific profile. Or another name more namespaced (quarto_profile() ? is_quarto_profile() ? when_quarto_profile() ? )