lovasoa / SQLpage

SQL-only webapp builder, empowering data analysts to build websites and applications quickly
https://sql.ophir.dev
MIT License
883 stars 64 forks source link

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

Open olivierauverlot opened 3 months ago

olivierauverlot commented 3 months ago

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

lovasoa commented 3 months ago

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?