elapouya / python-docx-template

Use a docx as a jinja2 template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how use vm tag in secondary loop table

user-tq opened this issue · comments

In the two-tier loop, vmtag doesn't seem to work as I expected.
is there anyway to do this?

from docxtpl import DocxTemplate

tpl = DocxTemplate('templates/vertical_merge_vm_loop2.docx')
tpl.render(
    {"allinfo":
     [
         { "gene":"EGFR","varlist":[
                                    {"varname":"L858R","varwithdrugs":[
                                                                        {"drugname":"A1","druglink":"A11","druginfo":"A111"}
                                                                        ] 
                                                                            },
                                    {"varname":"T790M","varwithdrugs":[ {"drugname":"B1","druglink":"B11","druginfo":"B111"} ]  }

                                                                             ]
                                                                                    },
         { "gene":"ALK","varlist":[
                                    {"varname":"fusion","varwithdrugs":[
                                                                        {"drugname":"C1","druglink":"C11","druginfo":"C111"},
                                                                        {"drugname":"D1","druglink":"D11","druginfo":"D111"}
                                                                        ] 
                                                                            },
            

                                                                             ]
                                                                                    }
        
        
        ]
        
        }

)
tpl.save('output/vertical_merge_vm_loop2_out.docx')

vertical_merge_vm_loop2.docx

image

I encountered the same problem