dongme8388 2019-06-23 15:42
浏览 36
已采纳

在使用opentbs创建docx时,是否可以在子块上使用子块?

I am trying to output an array to docx file with opentbs plugin. My array has a nested array so im using a block for the main array with a subblock for the nested array. This works perfectly. My problem is the nested array also has a nested array of its own. Is it possible to output this with a sub-subblock?

Below is what i'm using in the docx template, the shipment data(block) and the entries data(subblock) is displayed how i need. For each entry i need the packs(sub-subblock) to be displayed but at the moment it just outputs the tags and not the packs data. Where am i going wrong?

[a.shipment_#; block=tbs:row;sub1=entries]  
   [a_sub1.id]  
   [a_sub1.shipping_name;block=tbs:row;sub2=packs] 
   [a_sub1.total_quantity]  
        [a_sub2.display_line;block=tbs:row]
[a_shipment_total]

This is the array:

Array
(
    [0] =>; Array
        (
            [entries] =>; Array
                (
                    [1] =>; Array
                        (
                            [id] =>; 10000
                            [shipping_name] =>; Name1
                            [total_quantity] =>; 135                           
                            [packs] =>; Array
                                (
                                    [0] =>; Array
                                        (
                                            [display_line] =>; 6 Steel Drums x 10L
                                        )

                                    [1] =>; Array
                                        (
                                            [display_line] =>; 5 Steel Drums x 15L
                                        )

                                )

                        )

                    [2] =>; Array
                        (
                            [id] =>; 100001
                            [shipping_name] =>; Name2 
                            [total_quantity] =>; 50                           
                            [packs] =>; Array
                                (
                                    [0] =>; Array
                                        (
                                            [display_line] =>; 2 Plastic Jerry Cans x 25L
                                        )

                                )

                        )

                    [3] =>; Array
                        (
                            [id] =>; 10002
                            [shipping_name] =>; Name3
                            [total_quantity] =>; 170                          
                            [packs] =>; Array
                                (
                                    [0] =>; Array
                                        (
                                            [display_line] =>; 1 Plastic Jerry Can x 20L
                                        )

                                    [1] =>; Array
                                        (
                                            [display_line] =>; 6 Plastic Jerry Cans x 25L
                                        )

                                )

                        )                    

                )

            [shipment_id] =>; #1234
            [shipment_total] =>; 355
        )

)
  • 写回答

1条回答 默认 最新

  • dongshanjin8947 2019-06-23 18:49
    关注

    The sub-block feature does supports sub-sub-block.

    Block a_sub1 is the sub-block for block a.

    Block a_sub1_sub1 is the sub-block for block a_sub1, thus it is the sub-sub-block of 'a'.

    Here is how you template could be :

    [a.shipment_id;block=tbs:row;sub1=entries]  
       [a_sub1.id]  
       [a_sub1.shipping_name;block=tbs:row;sub1=packs] 
       [a_sub1.total_quantity]  
            [a_sub1_sub1.display_line;block=tbs:row]
    [a.shipment_total]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭