How about this 'iterate' simple iteration tag #208

wants to merge 1 commit into


None yet

2 participants



  • iteration tag
  • no testing code, sorry about my poor skill :(

plz, make better one.


<select id="birth_year" name="birth_year">
    {% set stYear = 1950 %}
    {% set edYear = 1999 %}
    {% iterate item with stYear to edYear %}
    <option value="{{ item }}">{{ item }}</option>
    {% enditerate %}


I love this killing 'swig' template for node.
this good for me. I used this all my project.
some time I have needed simple iteration tag
Is this useful? nor drop request.
I don't care for

Always thanks this code :)


There has been requests for this before. Other engines use syntax like {% for x in 1..5 %}, which then don't require another tag. The only issue with in the new syntax is that support for it needs to be bubbled everywhere.

I definitely see how this is useful, I'm just wondering about other approaches to solving the problem.

@paularmstrong paularmstrong commented on the diff Mar 18, 2013
@@ -0,0 +1,22 @@
+var require = require('../testutils').require,
+ expect = require('expect.js'),
+ swig = require('../../lib/swig');
+describe('Tag: iterate', function () {
+ beforeEach(function () {
+ swig.init({ allowErrors: true });
+ });
+ // it('simple test', function () {
paularmstrong Mar 18, 2013 Owner

Does this test not work?

sorry about that. I don't know how test code works and I am poor for code test framework.
I can not match the test result :(

when I made this code, I think that {% for x in 1..5 %} styles.
but hacks for.js tags not a simple for me. I decide only make simple code to generate the result.

be temporary used code is o.k.

by the way. 'swig' is so good enough for me and my project and node life. lol

soomtong commented May 9, 2013

I think this tag is not effective then use this iterate custom tag my friend

thanks cool swig!

@soomtong soomtong closed this May 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment