module Phlex::Collection
def yield_items
def yield_items if @item raise ArgumentError, "You can only yield_items when rendering a collection. You are currently rendering an item." end @collection.each_with_index do |item, index| @item = item @index = index @position = (index + 1) @first = (index == 0) @last = (@position == @collection.size) item_template end @item = nil @index = nil @first = nil @last = nil @position = nil end