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

knitr params specified in project profile ignored #84

Closed
gacolitti opened this issue Jan 24, 2023 · 4 comments
Closed

knitr params specified in project profile ignored #84

gacolitti opened this issue Jan 24, 2023 · 4 comments

Comments

@gacolitti
Copy link

gacolitti commented Jan 24, 2023

Here is a quarto document that prints out a knitr param value:

---
title: "test-quarto-profiles-static"
format: html
---

`r params$val`

Here is a _quarto.yml project profile file in the project root directory:

project:
  title: "test-quarto-profiles"
params:
  val: false

I expect params$val to be printed out, but instead I get an error: object `params` not found


I also tried specifying Knitr params using the quarto CLI described here:

quarto render doc.qmd -P val:true

but I get the same error.


How do I pass kintr params via profiles?

The goal is to list default params in the _quarto.yml file and create more profiles like _quarto-profile1.yml and _quarto-profile2.yml that can be selectively called to update the default params set in _quarto.yml.

@gacolitti
Copy link
Author

gacolitti commented Jan 24, 2023

If I add params to the top of the doc.qmd like this:

params:
  val: true

then render with:

quarto render doc.qmd -P val:false

I get the expected output (FALSE).

But I'm still not sure how to pass params in a _quarto.yml. Also, the -P argument to quarto render is not available with quarto serve for Shiny apps.

@gacolitti
Copy link
Author

gacolitti commented Jan 24, 2023

Okay, looks like you can render the HTML file and pass params, then serve the Shiny app without rerendering:

quarto render doc.qmd -P val:false

then

quarto serve doc.qmd --no-render

This seems like an okay workaround, but I'm not sure there is a way to publish to Posit Connect using this method. It seems that once deployed to Posit Connect the HTML file will be rerendered even if you upload the locally rendered HTML file.

@gacolitti
Copy link
Author

gacolitti commented Jan 24, 2023

Adding the following to _quarto.yml and uploading to Posit Connect solves the issue of rerendering when deployed to Posit Connect:

execute:
  freeze: true

@cderv
Copy link
Collaborator

cderv commented Jan 25, 2023

We don't currently support params at project level. See quarto-dev/quarto-cli#864 for current feature request

For now, params needs to be defined and set at the document level, and then each document render using command line or default value.

it seems you manage to do what you wanted so I'll close this, and you can follow the other issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants