webc icon indicating copy to clipboard operation
webc copied to clipboard

webc for loop

Open LegendT opened this issue 2 years ago • 2 comments

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.

LegendT avatar Jun 29 '23 16:06 LegendT

@zachleat Excellent report, this

Zearin avatar Aug 02 '23 14:08 Zearin

Use of instead of in

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

zeroedin avatar Sep 12 '23 13:09 zeroedin