Skip to content

Add "$foreach" statement. #278

@ciukstar

Description

@ciukstar

Add a new construct "$foreach" that works like $forall but yields the current element along with the remaining elements.

Usage:

[hamlet|
   <ul>
      $foreach (curr, rest) <- elements
          <li>#{show curr}
          $if not (null rest)
              <hr> 
|]

Compared with:

[hamlet|
    <ul>
         $with n <- length  elements
             $forall (i,curr) <- zip irange elements
                 <li>#{show curr}
                 $if i /= n
                     <hr>
|]

where 
    irange = [ 1 :: Int .. ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions