src/AbstractTemplate.php
public function loop(array $collection, string $block, string $emptyBlock = null): string
    {
        if (empty($collection)) {
            return isset($emptyBlock) ? trim($this->make($emptyBlock)) . PHP_EOL : PHP_EOL;
        } else {
            $items = '';
            foreach ($collection as $key => $item) {
                $items .= rtrim($this->make($block, ['key' => $key, 'item' => $item]));
            }

            return ltrim($items) . PHP_EOL;
        }
    }
public function loop(array $collection, string $block, string $emptyBlock = null): string
    {
        if (empty($collection)) {
            return isset($emptyBlock) ? trim($this->make($emptyBlock)) . PHP_EOL : PHP_EOL;
        } else {
            $items = '';
            foreach ($collection as $key => $item) {
                $items .= rtrim($this->make($block, ['key' => $key, 'item' => $item]));
            }

            return ltrim($items) . PHP_EOL;
        }
    }
public function loop ( array $ collection , string $ block , string $ emptyBlock = null ) : string { if ( empty ( $ collection ) ) { return isset ( $ emptyBlock ) ? trim ( $ this -> make ( $ emptyBlock ) ) . PHP_EOL : PHP_EOL ; } else { $ items = '' ; foreach ( $ collection as $ key => $ item ) { $ items .= rtrim ( $ this -> make ( $ block , [ 'key' => $ key , 'item' => $ item ] ) ) ; } return ltrim ( $ items ) . PHP_EOL ; } }
Renders a list.

@param array  $collection The collection.
@param string $block      The partition name.
@param string $emptyBlock The partition name for empty collection.

@return string Rendered items.
Renders a list .