How to Write Loops with Preprocessors

Programming - Mar 31, 2024

Loops are one of those features that you don’t need every day. But when you do, it’s awfully nice that preprocessors can do it because native HTML and CSS cannot.

Sass (SCSS)

for Loop

while Loop

each Loop

Less

for Loop

while Loop

(That’s what the above is. The when clause could be thought of exactly as while.)

each Loop

Stylus

for Loop

while Loop

Only for loops in Stylus.

each Loop

The for loop actually behaves more like an each loop, so here’s a more obvious each loop example:

Pug

for Loop

while Loop

each Loop

Haml

for Loop

while Loop

each Loop

Slim

for Loop

while Loop

each Loop

Previous Next
Copyrights
We respect the property rights of others, and are always careful not to infringe on their rights, so authors and publishing houses have the right to demand that an article or book download link be removed from the site. If you find an article or book of yours and do not agree to the posting of a download link, or you have a suggestion or complaint, write to us through the Contact Us .
Read More