views:

107

answers:

2

my code is :

class demo(BaseRequestHandler):
    def get(self):
        a=[[1,2,3],[3,6,9]]
        self.render_template('map/a.html',{'geo':a})

and the html is :

{% for i in geo %}
        <p><a href="{{ i[0] }}">{{ i[0]}}</a></p>
{% endfor%}

and the error is :

raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:]
TemplateSyntaxError: Could not parse the remainder: [0]

so what should i do .

thanks

+1  A: 

It doesn't mean you need to parse the remainder; it's saying the template engine tried to parse your i[0], understood i, but was unable to parse the remainder of the string, [0]. It looks like you can't index arrays that way; you may need to do something like this:

{% for i,j,k in geo %}
    <p><a href="{{ i }}">{{ i}}</a></p>
{% endfor%}
Michael Mrozek
+4  A: 

If you want the page to show the first item of each list:

{% for i in geo %}
  <p><a href="{{ i.0 }}">{{ i.0 }}</a></p>
{% endfor%}
Adam Bernier