I'm trying to make a concordance (ie, a list of a certain searchterm, including its surrounding context) and I can get it to work in the interpreter, but I'm having problems figuring out how to make it a list that I can pass it to the template. This is what works in the interpreter (tokens is a list of words which can be accessed by an index number, and offset is the index number corresponding to the searchterm):
>>> for offset in offsets: ... before = ' '.join(tokens[offset-5:offset]) #Takes the five preceding words and joins them in a string ... word = tokens[offset] #The searchterm occurance ... after = ' '.join(tokens[offset+1:offset+5]) #The five words after the searchterm ... print "%s %s %s" % (before, word, after) ... حنانلافاقتزاهيةتبرلي برشه وسيلة في العادة بكوشة فيهاشويةمشاكلوطلبةوشوية برشه حاجات يعني وكما تعرف يلقىحلعلىالخاطرتوا برشه ناس كما نحنا هكه بالكلّوالبلادقاعدةتخسرفي برشه م الشباب متاعها على كانطحانغيرهاوينوفمّه برشه ممّن تسّوللهم انفسهم الرخيصه I know you can't read the Arabic output that's written there, but it's exactly as it should be. Any way I've tried to get the before, word, after returned as variables (or lists of variables) so I can pass them to the template, it doesn't work. What I want to be able to do is something like this: {% for before, word, after in context %} <li>{{ before }} <bold>{{ word }}</bold> {{ after }}</li> {% endfor %} I just can't figure out how to do it... Can anyone point me in the right direction? Thanks, Karne -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.