• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it possible to use nested loops in parser templates?

#1
I am not sure if nested loops are supported by the parser, at least I am not able to display the following template correctly:
Code:
<table class="data_table">
  <thead>
    <tr>
      {header_entries}
        <th>{header_title}</th>
      {/header_entries}
    </tr>
  </thead>
  <tbody>
    {data_entries}
      <tr>
        {data_row}
          <td>{data_cell}</td>
        {/data_row}
      </tr>
    {/data_entries}
  </tbody>
</table>

The headers works but not the table's body when using these data:


Code:
   $header_entries = [['header_title' => 'one'],
                      ['header_title' => 'two']];
   $data_entries = [['data_row' => [['data_cell' => 'one - one'],
                                    ['data_cell' => 'one - two']],
                     'data_row' => [['data_cell' => 'two - one'],
                                    ['data_cell' => 'two - two']]]];
   $parser = \Config\Services::parser();
   echo $parser->setData(['header_entries' => $header_entries,
                          'data_entries' => $data_entries])->render('templates/data_table_template');
Reply


Messages In This Thread
Is it possible to use nested loops in parser templates? - by HardyW - 03-06-2019, 03:34 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.