Loops para todos los gustos

30/Sep/2014 288

En desarrollo front-end se da a menudo que tengamos etiquetas y selectores que se repitan varias veces, con la misma o diferentes clases ó valores que vayan en incremento/decremento. Pero como HTML y CSS no son lenguajes de programación (no tienen lógica asociada) esto no lo podemos automatizar.

Un loop es un bloque de código que se ejecuta tanto cuanto una condición sea verdadera (true).

Afortunadamente, los pre-processors que existen actualmente son basados en lenguajes de programación (JavaScript, Ruby, etc.) a los que podemos aplicar este y muchos otros tipos de lógica y que luego interpretan el código y lo compilan como HTML/CSS puro. En esta ocasión abordaré loops en los pre-processors más usados actualmente: [HTML] Jade, Slim, Liquid, Haml, [CSS] Less, Sass y Stylus

En los siguientes ejemplos, para cada pre-processor se iterará sobre sus elementos 10 veces:


- for (var x = 0; x < 10; x++)


- for i in (1..10)
  element #{i}


{% for x in (1..10) %}
  Element {{ i }}
{% endfor %}


- (1..10).each do |i|


.loop(@index) when (@index > 0){
  selector:nth-child(@{index}) { 
    property: @index * 1px; 
  .loop(@index - 1);


@for $i from 1 through 10
    property: $i * 1px


for $i in (1..10)
    property $i * 1px



  1. moncler [#]

    My wife and i have been really lucky when Albert managed to round up his researching with the precious recommendations he came across using your blog. It is now and again perplexing to simply possibly be releasing tricks which usually a number of people may have been selling. We know we need the blog owner to be grateful to for this. The specific illustrations you made, the easy website navigation, the relationships you give support to instill – it’s got most wonderful, and it’s really leading our son and us do think the subject matter is excellent, and that is wonderfully pressing. Thanks for the whole lot!

  2. off white jordan 1 [#]

    Thank you a lot for giving everyone remarkably pleasant opportunity to discover important secrets from this web site. It’s always so brilliant and also packed with a great time for me and my office friends to search your blog not less than thrice every week to see the latest stuff you have. And of course, I am also actually happy with your breathtaking guidelines you serve. Certain two points in this posting are in truth the simplest we’ve had.

  3. jordans [#]

    I want to get across my respect for your generosity giving support to those people that need guidance on this theme. Your special dedication to getting the solution all through had been astonishingly invaluable and has surely enabled ladies much like me to arrive at their endeavors. The valuable key points denotes a whole lot a person like me and a whole lot more to my office colleagues. Regards; from each one of us.

  4. jordan 4 [#]

    My wife and i felt so lucky Albert could conclude his survey while using the precious recommendations he acquired from your own site. It is now and again perplexing just to always be releasing thoughts which often other folks may have been selling. So we realize we need you to be grateful to for that. The entire explanations you’ve made, the straightforward web site navigation, the relationships you can help promote – it is mostly unbelievable, and it’s really assisting our son in addition to us imagine that this subject matter is entertaining, and that is especially vital. Thank you for the whole thing!

  5. moncler [#]

    I simply wished to thank you very much once more. I’m not certain the things I would have achieved in the absence of the type of tactics contributed by you regarding that problem. It truly was the terrifying setting in my opinion, but looking at the very well-written mode you dealt with that forced me to leap for contentment. Now i am happier for the advice and as well , have high hopes you know what a powerful job you are always accomplishing educating the mediocre ones with the aid of your blog. I am certain you have never encountered all of us.

  6. kyrie 5 [#]

    Thanks for all of your work on this web page. My daughter enjoys doing research and it’s easy to understand why. All of us hear all concerning the powerful medium you provide rewarding steps through your website and in addition strongly encourage contribution from other individuals about this concept so our favorite simple princess has been starting to learn a lot of things. Enjoy the rest of the year. You are carrying out a remarkable job.

  7. Garcheedarap [#]

    buy prednisone dose pack

  8. cost of tadalafil in mexico [#]

    Greetings! Very helpful advice within this post! It is the little
    changes that will make the biggest changes. Thanks a lot for
    sharing! https://tadalafili.com/

  9. cetirizine 10 mg [#]

    what is cetirizine – http://allergyd.com

  10. www.pharmaceptica.com [#]

    tadalafil cost https://pharmaceptica.com/

  11. zyrtec walmart [#]

    cetirizine side effects – https://allergyd.com

  12. zyrtec over the counter [#]

    ranitidine – http://allergyd.com

  13. zyrtec with decongestant [#]

    fexofenadin – http://allergyd.com

  14. curry 8 [#]

    I want to get across my respect for your kind-heartedness in support of men and women that absolutely need help with your subject matter. Your very own dedication to getting the message all through became rather good and has truly made individuals just like me to reach their pursuits. This helpful report means a great deal a person like me and extremely more to my office workers. Warm regards; from all of us.

  15. kd 12 shoes [#]

    I and also my guys happened to be reading through the best tactics found on your web site and so all of a sudden came up with an awful feeling I never expressed respect to the site owner for those secrets. These people became as a result excited to see all of them and already have in actuality been enjoying those things. Appreciate your simply being really considerate and for pick out this kind of smart subject areas millions of individuals are really needing to learn about. Our sincere apologies for not expressing appreciation to sooner.

  16. goyard [#]

    I in addition to my pals were reviewing the great points located on your web page then at once I got an awful feeling I had not expressed respect to the site owner for them. My guys were as a consequence joyful to see them and have now clearly been taking advantage of them. We appreciate you simply being indeed considerate as well as for using this kind of magnificent subject areas most people are really needing to learn about. Our own sincere apologies for not expressing gratitude to sooner.

  17. irving shoes [#]

    I wanted to put you a bit of remark just to say thank you again for these superb strategies you have featured in this case. It’s certainly particularly open-handed with you to convey publicly just what most of us would’ve offered for sale for an e-book to earn some cash for themselves, principally considering that you could have tried it if you ever decided. Those things also served to provide a good way to fully grasp that other people online have the identical passion just like my very own to see a good deal more when considering this issue. I think there are some more pleasant times in the future for folks who start reading your blog.

  18. how does accutane work [#]

    what is accutane https://isotroinisotretinoin.com/

  19. pharmacepticacom [#]

    erectile organs crossword clue https://www.pharmaceptica.com/

  20. drineemqnj [#]

    modafinil prescription https://modafinilpleasure.com/

  21. bactrim generic [#]

    sulfamethoxazole trimethoprim sulfameth trimethoprim 800 160 tb

  22. accutane coupon [#]

    accutane side effects isotretinoin side effects

  23. buymodalertreddit [#]

    provigil dosage how long does modafinil last

  24. bactrim and alcohol [#]

    sulfamethoxazole side effects trimethoprim class

  25. ivermektin 10 mg [#]

    stromectol 3 mg tablets price https://stromectolforte.com/# stromectol ivermectin for sale

  26. cheap jordans [#]

    I precisely wished to appreciate you all over again. I do not know what I might have carried out without the entire solutions shared by you about that question. It has been the fearsome setting in my position, however , seeing the very well-written style you processed the issue took me to cry for gladness. Extremely thankful for this service and as well , hope you recognize what a powerful job that you’re getting into instructing the mediocre ones via your webpage. I am sure you haven’t encountered all of us.

  27. nike kyrie 7 [#]

    I must express some appreciation to this writer for rescuing me from this type of scenario. Because of browsing through the world-wide-web and finding proposals that were not powerful, I figured my life was gone. Living without the answers to the difficulties you’ve sorted out by means of your entire guide is a serious case, as well as those that could have in a negative way affected my entire career if I had not encountered your web blog. That skills and kindness in maneuvering all the things was crucial. I’m not sure what I would’ve done if I hadn’t come upon such a point like this. It’s possible to now look forward to my future. Thanks very much for this skilled and result oriented help. I will not think twice to refer your web sites to any person who requires direction on this matter.

  28. jordan 11 [#]

    A lot of thanks for every one of your efforts on this web site. My daughter takes pleasure in getting into internet research and it’s simple to grasp why. My partner and i learn all about the dynamic manner you make functional secrets via your website and as well inspire participation from other ones about this concept and our girl is without question learning a whole lot. Take pleasure in the remaining portion of the year. Your carrying out a brilliant job.

  29. hermes online [#]

    I intended to post you one little note to help say thanks again for the pleasing knowledge you’ve shared above. It was simply strangely open-handed of you to make freely just what a few people could possibly have made available as an e-book to earn some money for their own end, chiefly considering the fact that you could have done it in case you considered necessary. Those things likewise acted to be a fantastic way to realize that the rest have similar zeal just like my very own to know the truth very much more with regards to this condition. I am sure there are thousands of more enjoyable instances up front for folks who see your site.

  30. curry 7 [#]

    I must get across my affection for your generosity in support of those individuals that should have help on this important issue. Your personal dedication to getting the solution all over had been surprisingly advantageous and have without exception allowed women much like me to realize their dreams. Your important facts indicates a lot to me and substantially more to my colleagues. Warm regards; from all of us.

  31. ivermektin 1 krem ​​jenerik [#]

    ivermectin where to buy http://stromectolforte.com/# stromectol stromectol 3mg cost

  32. stromectol [#]

    ivermectin buy nz https://stromectolforte.com/ ivermectin iwermektyna dla ludzi

  33. stromectolforte.com [#]

    ivermectin for humans amazon http://stromectolforte.com/# how much does ivermectin cost stromectol

  34. modafinilotc [#]

    modafinil half life modafinil for sale

  35. buy accutane [#]

    buy isotretinoine roaccutane

  36. steroidprednisone [#]

    does prednisone raise blood pressure prednisolone for dogs

  37. kawhi leonard shoes [#]

    Thank you so much for providing individuals with such a terrific possiblity to read articles and blog posts from this blog. It is always so lovely and stuffed with a good time for me personally and my office fellow workers to visit the blog really thrice every week to learn the new items you have. Not to mention, I’m also certainly fascinated with your staggering things you give. Some 1 ideas on this page are particularly the most beneficial I have had.

  38. bactrim dosing [#]

    https://bactrimsulfamethoxazole.com/ trimoxazole antibiotics