python - tal nested dictionary syntax -


working pyramid, code looks this:

class pagedata:     @staticmethod     def create_data():         return [             {                    'key_1a': 'info1a',                 'key_2a': 'info2a',                 'nested_list_a': [                     {'nested_key1a': 'nested_val1a'},                     {'nested_key2a': 'nested_val2a'},                 ],             },             {                    'key_1a': 'info1b',                 'key_2a': 'info2b',                 'nested_list_b': [                     {'nested_key1b': 'nested_val1b'},                     {'nested_key2a': 'nested_val2a'},                 ],             },             ] 

and html page code looks this:

<span tal:condition="nested_key1a">     open     </span> <span tal:condition="not nested_key1a"> closed   </span> 

what proper syntax reference nested_key? tal:condition statement?

in trying figure out found answer...

tal:repeat syntax: tal:repeat="name expression"

description: evaluates "expression", , if sequence, repeats tag , children once each item in sequence. the "name" set value of item in current iteration, , name of repeat variable. repeat variable accessible using tal path: repeat/name , has following properties:

https://www.owlfish.com/software/simpletal/tal-guide.html

<div tal:repeat="a nest_list_a"> <div tal:repeat="b a.nest_list_a"> <span tal:condition="b.nested_key1a"> 

a becomes assignment nest_list_a eg b becomes assignment a.nested_list_a access key

if there value key, tal:condition continue normal, otherwise skip while rendering.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -