vapor / leaf-kit

🍃 An expressive, performant, and extensible templating language built for Swift.
https://docs.vapor.codes/4.0/leaf/getting-started
MIT License
49 stars 38 forks source link

Add modulo (%) infix operator #87

Closed fananek closed 3 years ago

fananek commented 3 years ago

Description

Modulo (%) operation is not supported at the moment. It can be used e.g. for calculation even/odd rows. Zebra striped tables or grids are pretty common design requirement.

example psudo-code:

#for(row in rows)
  #if(index % 2 == 0):
    // use row backgroud color
  #else:
    // use row alternate backgroud color
  #endif
#endfor

Solution

Implement function which handles modulo operation for Int as well as Double input values. Already working on pull-request.

grundoon commented 3 years ago

(@fananek just a pointer to how I implemented it for Leaf 1.x https://github.com/vapor/template-kit/pull/19)

fananek commented 3 years ago

@grundoon Thanks, but it's not relevant anymore. Leaf has been completely rebuilt. I have it almost ready for Leaf 4. Just making few more tests.

0xTim commented 3 years ago

Closed via #88