Skip to content

feat: Implement loop control structures (@foreach, @endforeach) #4

@benkhalife

Description

@benkhalife

Description

To handle arrays and collection rendering elegantly, we need to introduce loop directives. Adding support for @foreach will significantly reduce boilerplate code when rendering dynamic lists or tables in Webrium View.

Proposed Syntax

<ul>
    @foreach($items as $item)
        <li>{{ $item->name }}</li>
    @endforeach
</ul>

Expected Behavior

The template engine should compile @foreach($a as $b) into and @Endforeach into .

Checklist

  • Implement parser for @foreach(...) mapping to native PHP loops.
  • Implement parser for @Endforeach.
  • Handle nested loops correctly without breaking the scope.
  • Add unit tests for looping through various data structures (arrays, objects).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions