I'm trying to display all the users in my User object without knowing the structure of the object (so I can use the same table to display other collection of objects as well).
This is what it would look 'statically':
<table>
<tr>
<td>id</td>
<td>username</td>
</tr>
{% for item in entities %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.username }}</td>
</tr>
{% endfor %}
</table>
What i would want to do is something as follows (this is just to display what I'm trying to do, but its not even close to working):
<table>
<tr>
{% for property_title in entities.item[0] %}
<td>{{ property_title }}</td>
{% endfor %}
</tr>
{% for item in entities %}
<tr>
{% for property in item %}
<td>{{ property.value }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
Result should be something as follows:
<table>
<tr>
<td>id</td>
<td>username</td>
</tr>
<tr>
<td>1</td>
<td>Mike123</td>
</tr>
<tr>
<td>2</td>
<td>jesica2</td>
</tr>
</table>
PD: this is my first post, so apologies if I missed something.
$property
) first ... and if that doesn't work (i.e. due to the property being private/protected ) ... try to invoke the corresponding getter methodgetProperty()
when using the.
notation. Souser.name
does fail$name
is private/protected and there is nogetName()
function. – Lauzon