github alpinejs/alpine v2.0.2
on GitHub


  • For (item, index, group) in items, index and group weren’t being made available to elements inside an x-for <template> tag. Now they are #208
    html <div x-data="{ items: ['foo'] }"> <template x-for="(item, index) in items"> <div> <h1 x-text="items.indexOf(item)"></h1> // Same as... <h2 x-text="index"></h2> </div> </template> </div>
    * Using x-for and x-if in conjunction (<template x-for="..." x-if="...">) resulted in odd behavior. It is now fully possible and supported #208
    html <div x-data="{ items: ['foo', 'bar'], show: false }"> <button @click="show = ! show"></button> <template x-if="show" x-for="item in items"> <span x-text="item"></span> </template> </div>
5 months ago