how to create multicolumn layout in a loop?

I would like to re-write this code to include in a loop to create Section 1 and section 2

---
output: html_document
---

# Section 1
:::: {style="display: flex;"}

::: {}
Here is the **first** Div.

```{r}
str(iris)
```
:::

::: {}
And this block will be put on the right:

```{r}
plot(iris[, -5])
```
:::

::::


# Section 2
:::: {style="display: flex;"}

::: {}
Here is the **first** Div.

```{r}
str(iris)
```
:::

::: {}
And this block will be put on the right:

```{r}
plot(iris[, -5])
```
:::

::::



You should find some helpful recipies in the Cookbook, focusing on child document to loop through with variables

Hope it helps

Hi...
i am sorry for the late reply. i tried this and i failed. i am wondering what i did wrong!!!!

```{r echo = FALSE, results = 'asis'}
cat('\n\n# Section 1\n\n:::: {style="display: flex;"}\n\n::: {}\nHere is the **first** Div.\n')
str(iris)
cat(':::\n\n::: {style="width:30px;"}\n:::\n\n::: {}\nAnd this block will be put on the right:\n\n')
plot(iris[, -5])
cat('\n:::\n\n::::\n\n')
```

str(iris) is not outputing a string that can be inserting as you expect with result = "asis".
This is usually the work of knitr to weave together code output and text, you are by passing that.

You could make it work by processing str(iris) to build some string content to write as markdown. But this would be more work that using knit_child() or a template.