Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variables only available in projects #1252

Closed
6 tasks done
aronatkins opened this issue Jun 29, 2022 · 2 comments
Closed
6 tasks done

variables only available in projects #1252

aronatkins opened this issue Jun 29, 2022 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@aronatkins
Copy link
Contributor

Bug description

Tested with Quarto 0.9.629 (inside RStudio 2022.10.0 Build 9) and 0.9.607 (outside RStudio).

Using an index.qmd as a non-project Quarto document:

---
title: non-project document with variables
---

Apple cider donuts are {{< var reaction >}}.

This document expects values set in the _variables.yml:

reaction: awesome

When rendering, we get a warning about the unknown variable:

quarto render index.qmd
# ...
# => WARNING: Unknown var reaction specified in a var shortcode.

The rendered HTML has the variable reference replaced by ?var:reaction.

Creating an empty _quarto.yml is enough to cause this document to be processed as part of a project, and lets the variable get resolved.

touch _quarto.yml

Checklist

  • formatted your issue so it is easier for us to read?
  • included a minimal, self-contained, and reproducible example?
  • documented the quarto version you're running, by providing the output produced by quarto check in a terminal in your issue?
  • documented the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • documented which operating system you're running? If on Linux, please provide the specific distribution as well.
  • upgraded to the latest version, including your versions of R, the RStudio IDE, and relevant R packages?
@aronatkins aronatkins added the bug Something isn't working label Jun 29, 2022
@jjallaire jjallaire added this to the Future milestone Jun 30, 2022
@cscheid
Copy link
Collaborator

cscheid commented Jun 30, 2022

@aronatkins We'll add an warning in the future about variables.yml being a project-only feature.

Would using {{< meta >}} work in your case? You can specify pretty much arbitrary metadata on the yaml front matter, after all..

---
title: "hello"
reaction: awesome
---

You are {{< meta reaction >}}.

@aronatkins
Copy link
Contributor Author

@cscheid - I'm now using environment variables to share configuration information across all the places. I was searching for an option that would let me obtain values in prose, the document title, and executable code.

Environment variables have been sufficient for my needs, as I can use language-specific ways to read them in combination with the {{< env XX >}} shortcode. I've put an example of my approach here: #1237 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants