lektor checkboxes `[u'` ouput error?

98 views Asked by At

my first attemp in lektor: I want to create my own Data Model for architectural works record. I have a wierd ouput for checkboxes and lists like:

    [u'corporate & commercial', u'interiors']

Where the poject.ini is

[fields.type]
label = Project type
type = checkboxes
choices = corporate & commercial, residential, interiors, public,hotel/tourism, university, art gallery, restoration, spa, auditorium,  installations, landscape
choice_labels = corporate & commercial, residential, interiors, public, hotel/tourism, university, art gallery, restoration, spa, auditorium,  installations, landscape

and the project.html has:

{% if this.type %}
<tr>
<th scope="row">Type</th>
<td>{{ this.type}}</td>
</tr>
{% endif %} 

Where are those [u' in the ouput coming from? What am I missing?

Thank you

AR (running lektor 3.0.1 on win 7/64)

2

There are 2 answers

1
mj241 On BEST ANSWER

When you call {{ this.type }}, you’re getting the full, raw results of your entire array.

Having looked at your example page, it looks like what you’re aiming to do is to call each item separately as a list. To do this, you need to loop through the array:

{% for item in this.type %}{{ item }}{% if not loop.last %}, {% endif %}{% endfor %}

This should output as ‘Item 1, Item 2, Item 3’. If you want to change the separator, edit the bit between {% if not loop.last %} and {% endif %}.

1
Ekkart Kleinod On

The [u indicates a list (or array). this.type is your list of choices, to get one item, you can use a for loop or a filter or such.