SQLpage icon indicating copy to clipboard operation
SQLpage copied to clipboard

each_row help can't be used in a {{else}}...{{/if}} block

Open olivierauverlot opened this issue 11 months ago • 1 comments

Introduction

each_row helper can't be used in a {{else}}...{{/if}} block

To Reproduce

<div>
{{#if menu}}
A menu
{{else}}
    {{#each_row}}
        {{title}}<br>
    {{/each_row}}
{{/if}}
</div>
select
    'foo' as component;
select
    'a' as title;
select
    'b' as title;
select
    'c' as title;

Actual behavior

I got the error message :

Sorry, but we were not able to process your request. 

Failed to create a render context from the header context.: Error rendering "Unnamed template" line 5, col 5: Helper not found each_row: Helper not found each_row

Version information

  • OS: Linux (ChromeOS)
  • none
  • SQLPage Version : 0.19.1

olivierauverlot avatar Mar 10 '24 08:03 olivierauverlot

Hello Olivier, and thanks for opening this!

Indeed, the each_row template has to be at the "top level" of a template (not nested in another block).

This limitation would be quite hard to overcome without major changes either in the template library we use or in the ability of SQLPage to stream contents to browsers efficiently.

So unfortunately, this limitation is unlikely to be lifted soon.

What was your use case for it? Maybe we can find an effective workaround?

Maybe we can improve the error message too to make the situation clear?

lovasoa avatar Mar 10 '24 10:03 lovasoa