Open zeehio opened 7 years ago
What if we just added support for a params
argument for the render_site
function? We could furthermore allow this parameter to be the path to a YAML file.
That would be great!
My only concern is that the same .Rmd
file may be used as the input file for several output html files (with different parameters) and the params
argument should be able to accept that use case.
Looking at the render
function in the default_site, when it wants to do an "incremental" rendering, it is based on the input_file
. This is fine if there is a single output file for each input file, but it gets a bit confusing in the case where we have a single Rmd file generating several html files.
To me it would make more sense to say "render this output file" and then it would render it using the corresponding Rmd input file and parameters... but maybe I am missing something or overcomplicating things...
Thanks for the quick reply on a Sunday... I wasn't expecting that :open_mouth: :+1:
I get it now, you want to use a single Rmd as a template for multiple distinct output files. That makes a tremendous amount of sense. Yes, I think it would be good to have support for this built in so I would take a PR. What would you think about the YAML being "output_files" rather than "files"?
On Sun, Dec 4, 2016 at 7:04 AM, Sergio Oller notifications@github.com wrote:
That would be great!
My only concern is that the same .Rmd file may be used as the input file for several output html files (with different parameters) and the params argument should be able to accept that use case.
Looking at the render https://github.com/rstudio/rmarkdown/blob/master/R/render_site.R#L170 function in the default_site, when it wants to do an "incremental" rendering, it is based on the input_file. This is fine if there is a single output file for each input file, but it gets a bit confusing in the case where we have a single Rmd file generating several html files.
To me it would make more sense to say "render this output file" and then it would render it using the corresponding Rmd input file and parameters... but maybe I am missing something or overcomplicating things...
Thanks for the quick reply on a Sunday... I wasn't expecting that 😮 👍
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rstudio/rmarkdown/issues/903#issuecomment-264699970, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGXx-RoLIWoDOdo0DqgxLKjn63w55Eoks5rEqxagaJpZM4LDj7O .
I thought it would be better to do a PR with the changes and if necessary do further discussion there.
We were lucky and I also fixed #892 with almost zero extra effort. Looking forward to the next release! :smiley:
@zeehio I'm going to take this PR back up after the next CRAN release (2 or 3 weeks out).
@jjallaire this is just a kind reminder of the issue, given your previous comment of taking the PR back up after the 1.3 release :+1:
@zeehio Sorry for leaving this issue aside for so long. Bad news is we probably still don't have the bandwidth to review your PR. I have currently scheduled it for v1.8, the next version after 1.7 (no ETA yet; probably early next year). I'd appreciate it if you could resolve the GIT conflicts before then.
@yihui, I fully understand the bandwidth limitations. Like you, I am a bit full until mid January, but I will do my best to find the time to resolve conflicts. I appreciate a lot your kind reply, keep up doing your great work!
Just came across this - any chance this was ever integrated? I could certainly use this functionality in some course sites I'm building.
As far as I know, the option of passing parameters to Rmd files through render_site()
was not implemented.
I believe my pull request had some room for improvement and I discarded it. I think there was some interest by rmarkdown maintainers to keep render_site()
functionality simple (or at least not more complex) and someone suggested that for such functionality maybe another package would be a better suit.
I have no idea and I don't need this functionality anymore, but I would check other packages (blogdown maybe?)
I started to use the
rmarkdown::render_site
function. At some point I had anRmd
file with parameters, and I wanted to render it several times with different options.To do that, I adapted a custom site generator. I would like to know if you are interested in a pull request or at least export some functions so I don't need to use
:::
.render_site with rmarkdown parameters
I wrote a custom site generator named
site_with_params
based ondefault_site
. The main changes with respect to the default_site are:index.Rmd
needs to havesite: site_with_params
to use this site generator.files
section to_site.yml
is required, that states how html files need to be rendered. An example of_site.yml
is shown here (note the "files" section):Questions
rmarkdown:::site_config
,rmarkdown:::input_as_dir
,rmarkdown:::knitr_files_dir
,rmarkdown:::dir_exists
,rmarkdown:::copy_site_resources
andrmarkdown:::knitr_root_cache_dir
so it is easy to provide custom site generators in other packages?Actual code
The code I wrote is adapted from
default_site
and uses several non-exported rmarkdown functions.This could be submitted as a PR if there is interest: