-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/07/2015 03:33 AM, Sami Pietilä wrote:
> I have a database containing JSON objects. The database JSON contain
> a block named "keys". (For example: "keys": [{...}, {...}])
>
> I am trying to render the keys block with chameleon template with
> tal:repeat="key record.keys". It seems that this syntax somehow fails
> to handle JSON if it has a block called "keys".
>
> Can I use some other syntax for tal:repeat which do not fail to "keys"
> value? I have tried to write this differently like: tal:repeat="key
> record['keys'], but it did not seem to work either.
I just created a project using the Pyramid 'starter' template, and edited
the 'mytemplate.pt' Chameleon template to include the following:
<ul>
<li tal:repeat="key document['keys']">Key: ${key}</li>
</ul>
I then updated the 'views.myview' function to return a document with 'keys':
@view_config(route_name='home', renderer='templates/mytemplate.pt')
def my_view(request):
return {'project': 'chammy',
'document': {'keys': ['AAA', 'BBB', 'CCC']},
}
The view/template renders the keys as expected.
Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 [email protected]
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBAgAGBQJWFVnMAAoJEPKpaDSJE9HY3xUP+gIAOvssSsgBqU/IWutxdEtG
L8310KWQnauLXVopxp/KPnvSTFzwciBc+U0OMrD980OAk1Kh8ATlEevihErN27sZ
zEwOqlq+2t1saV8rYWKNjkcj4QPAuIdJyI+vFvf0juBnrLUkJpXCnp+lawSX2dLJ
uOAVyxjMQzs1/9+LwJsjezpXQ45UkIbn6GDQ8OcmFjBhx+JQVjmWMjXIcku4Ar01
bs1TsvvaDT8KpyujVKymfc+kssYzTGG7/lQ5CuUV8jQK/9PYRDcWTMeLrVOYHR98
8hKRTdLZwAiKdBNrAM6Aftg1Ii/MzVCC+unolrsh2choFOhmDPDfLeQxqoLEGqfB
gJG1NaDGSCsmyWsMl5RzJg5DyEe5DCiOBVOp8XBU9drNn4hYKVNtGaOVGZBtJTDM
C/WOVoK5Y/J+vQPTDIR+3s1fwwmlXMhqnBAyEF9ZbUFfaekphR7EvFnwEDNnpE2N
pmXlo9KttqktGuAg6QL8DEbNrYCN0UpDedIPtzrtM/jTfMtrcSOlxSqByCH2vkYL
9TnDMXbnNJeFCf5Gl5mUC4rspUP4+V5EimDBSUTc2OTA7LIo21keOe0drSB9/jXO
4rCcnhy5QIlfPS3pDuUMv/KxtZ8XimIWrNsMXCuWpW9Se9sp4GL+QXo+zO3fSSui
KrjGFh6pOxDxSZRyPmKZ
=IOuX
-----END PGP SIGNATURE-----
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.