Skip to content

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

Open

Description

@olivierauverlot

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

Activity

  1. lovasoa commented on Mar 10, 2024

    @lovasoa
    Collaborator

    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?

  2. 81reap commented on Oct 29, 2026

    @81reap
    Collaborator

    I think this is still an issue

    reproduction

    $ cat tests/end-to-end/fixtures/repro_261/index.sql 
    SELECT 'text' AS component, 'repro' AS contents;
    
    $ cat tests/end-to-end/fixtures/repro_261/test.ts 
    import { expect, test } from "../../fixture.ts";
    
    test("each_row renders inside an else block", async ({ page }) => {
      await page.goto("/repro_261/page.sql");
      await expect(page.locator(".item")).toHaveText(["a", "b"]);
    });
    repro_261 postgres
    v0.36.0 ✘ failed
    v0.47.0 ✘ failed
    tree ✘ failed

    On commit 616df27: nix run .#reproduce -- repro_261 postgres v0.36.0 v0.47.0 tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions