Setting up custom html content on Leafy map marker popup

I’d like to generate custom HTML for a list of data, but when I try to put HTML using the ‘arbitrary text’ and ‘format as text’ option, it doesn’t work for a list of data; it considers it as a single data entry. So I put the pre-generated HTML from the API, which makes the API data heavier.