Dynamic INCLUDEs in QMD files #12081
Replies: 1 comment
-
Why not use project profiles and conditional contents? Edit: actually it does (now) work but included files via computations won't have their code cell computed. Outdated comment (Quarto >1.6)
Because ```{python}
#| echo: false
#| output: asis
print('\n\n{{< include "_sample1.qmd" >}}')
``` The above does not do what you think. |
Beta Was this translation helpful? Give feedback.
-
Description
My goal is to dynamically write INCLUDE shortcodes in my master document. I'm creating a revealjs slide deck and want to keep separate topic files containing graphics, etc. In my production code I'm dynamically including topics from a list.
In the simple example below I demonstrate two ways to INCLUDE my topic files in an HTML output file. The first is by direct include. The second is by writing the includes to the output stream from python for later processing.
When rendered, the graphviz figure in properly created in first example. In the second example, the graphviz code is displayed as code in a code block, rather than rendered as a figure.
The INCLUDE documentation discusses *computations" inside includes. I expect that this is the issue.
Any suggestions for workarounds? Is there a quarto hook that will allow me to expand or pre-render the content of the include file and then drop the contents into the output stream.
To run the example, store the first block in a file named test.qmd and the second file in _sample.qmd, and then render test.qmd
Here is a the _sample.qmd file:
And the particulars of my installation.
Thanks again for any suggestions or tips!
Beta Was this translation helpful? Give feedback.
All reactions