I am curious if there is any way to enable using for-loops within tabsets in a user-friendly manner for Quarto. There is a convoluted workaround for doing it in RMarkdown using R code and exploiting calls to the console via `cat()`, but I don't know of a means of accomplishing the same result in Python. I also don't know much about how the rendering is done at the lower-levels, so I am not sure if this is even a reasonable ask. I find the tabsets to be very useful for presentations of results and use them quite frequently for demonstrating the effect of different variables or generating figures for a large number of samples. It would be awesome to have a more efficient way to do it, and also a means with Python!

Here is a.. mostly.. minimal working example of the way that I know of to accomplish what I am referring to with R, 

```{r, data}
iris2 <- data.table::data.table(iris)
```
```
# Single Tabset Loop {.tabset .tabset-pills}
```{r, single_loop, results='asis'}
for(variable in colnames(iris2[,-'Species'])){
  cat("##", variable, '<br>', '\n\n')
  g <- ggplot2::ggplot(data=iris2, ggplot2::aes_string(x=variable, fill='Species')) + 
    ggplot2::geom_density(stat="density", alpha=0.2)
  print(g)
  cat('\n', '<br><br><br>', '\n\n')
}
```
```
# Nested Tabset Loop {.tabset .tabset-pills}
```{r, nesteed_loop, results='asis'}
iris2 <- data.table::data.table(iris)
for (i in seq_along(levels(iris2$Species))){
  species <- levels(iris2$Species)[i]
  cat('## ', species, '{.tabset .tabset-pills}', '\n', '<br>', '\n\n')
  for(variable in colnames(iris2[,-'Species'])){
    cat("###", variable, '<br>', '\n\n')
    g <- ggplot2::ggplot(data=iris2[Species %in% species], ggplot2::aes_string(x=variable)) + 
    ggplot2::geom_density(stat="density", alpha=0.2, fill = c("#F8766D", "#00BA38", "#619CFF")[i])
    print(g)
    cat('\n', '<br><br><br>', '\n\n')
  }
cat('\n', '<br><br><br>', '\n\n')
}
```



2021-08-13T20:52:15Z
schuyler-smith
closed
generate tabset elements using for-loops
https://github.com/quarto-dev/quarto-cli/issues/89