sempare / sempare-delphi-template-engine

Sempare Template (scripting) Engine for Delphi allows for flexible dynamic text generation. It can be used for generating email, html, reports, source code, xml, configuration, etc.
Apache License 2.0
144 stars 18 forks source link

add 'else' , 'onfirst', 'onlast', 'onloop' to 'for' loop #61

Closed sempare closed 1 year ago

sempare commented 2 years ago

this is useful for cases when the for loop is empty and means the developer does not need to create an additional if statement.

e.g.

<% for x in items %>
    <% onfirst %>
        <ol>
   <% onlast %>
        </ol>
   <% onloop%>
        <li>item: <% x %></li>
    <% else %>
    there are no items.
<% end %>
darnocian commented 1 year ago
<% for x in items %>
     <li>item: <% x %></li>
    <% onbegin%>
        <ol>
   <% onend %>
        </ol>
    <% onempty %>
    there are no items.
<% end %>
darnocian commented 1 year ago

It applies to while loops as well