How about this 'iterate' simple iteration tag #208

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@soomtong

Include

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

plz, make better one.

Usage

<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 %}
</select>

Comment

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 :)

Owner

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
tests/node/tags/iterate.test.js
@@ -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
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
https://gist.github.com/soomtong/5465411

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