Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser is not able to handle nested loops #1799

Closed
hwiesmann opened this issue Mar 8, 2019 · 3 comments
Closed

Parser is not able to handle nested loops #1799

hwiesmann opened this issue Mar 8, 2019 · 3 comments

Comments

@hwiesmann
Copy link


Describe the bug
The parser is not able to handle nested loops (code and output example below).

CodeIgniter 4 version
CodeIgniter4 Alpha 4

Affected module(s)
Parser

Expected behavior, and steps to reproduce if appropriate
Assume the following template

<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>

with these input values and 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');

The expected output is:

one two
one - one one - two
two - one two - two

Unfortunately the output is
one two
two - one two - two

{header_entries} specifies a single loop. This works because the first line in the output is correct. {data_entries} and {data_row} specify an outer and an inner loop. The output of these loops is not correct.

@InsiteFX
Copy link
Contributor

CodeIgniters Parser never did handle handle nested loops.

@lonnieezell
Copy link
Member

Agree with @InsiteFX and, while it would be great if someone wanted to tackle that - it's pretty low on my list currently and isn't a priority for 4.0 final.

@hwiesmann
Copy link
Author

Then, I think that this should be documented before other people waste their time on trying same things as I did. I will create a new documentation issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants