11ty / webc

Single File Web Components
MIT License
1.3k stars 36 forks source link

webc for loop #186

Open LegendT opened 1 year ago

LegendT commented 1 year ago

This may be the same issue as https://github.com/11ty/webc/issues/179

band.md

---
layout: band_profile.webc
bandName: The Band
bandBio: The Band Bio
bandVideos:
  - videoID: shEPwQPQG4I
    videoName: Snotty
  - videoID: ykn4XNDwW7Q
    videoName: Kev Dev
---

band_profile.webc

<div webc:if="bandVideos">
    <h2>Band Videos</h2>
    <p @text="bandVideos[0].videoID"></p> // this works
    <youtube-embed
        webc:for="bandVideo in bandVideos"
        :@videoid="bandVideo.videoID" // This does not work
    ></youtube-embed>
</div>

Issue Description:

The bandVideos array is not being rendered correctly in the band_profile.webc file. The youtube-embed element is not being rendered correctly. The expected behaviour is for the bandVideos array to be rendered with each youtube-embed element displaying the videoID of the corresponding object in the array.

Expected Results:

The bandVideos array should be rendered correctly with each youtube-embed element displaying the videoID of the corresponding object in the array.

Actual Results:

The bandVideos array 'videoID' is not being rendered in the band_profile.webc file.

Zearin commented 11 months ago

@zachleat Excellent report, this

zeroedin commented 9 months ago

Use of instead of in

    <youtube-embed
        webc:for="bandVideo of bandVideos"
        :@videoid="bandVideo.videoID" 
    ></youtube-embed>