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:
<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
Post a Comment