You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"each_row" helper cannot contain calls to inline partials. #846
When SQLPage encounters an each_row helper, it splits the template at that point using the split_template function. This function extracts the content inside the each_row block into a separate template (list_content), with everything before it going into before_list and everything after into after_list.
The problem occurs because inline partials defined with {{#*inline "name"}}...{{/inline}} are registered in the Handlebars registry during the initial template parsing. However, when the template is split, these inline partial definitions remain in the before_list section, but the list_content template (which contains your each_row content) becomes a separate template context that doesn't have access to those inline partials.
In the render_item method of SplitTemplateRenderer, when it tries to render each row, it's using the isolated list_content template which can't see the inline partials defined in the parent template.
This is why you're seeing the "Partial not found item" error - the {{> item }} reference inside your each_row block is looking for a partial that isn't accessible from that context.
Possible workarounds:
Use direct HTML in the each_row block instead of a partial
Define the partial inside #each_row
This is a limitation of how SQLPage processes templates to support its streaming row-by-row rendering model, which is different from standard Handlebars processing.
Thank you @lovasoa for this detailed answer. This is very useful information indeed. Workaround 1 is not applicable to our use case, as it would lead to a lot of hard-to-maintain duplication of code. Workaround 2, even though not ideal, is a workable solution. So, thanks again and keep up the good work!
Activity
lovasoa commentedon Mar 6, 2025
The issue you're experiencing with inline partials not working inside
each_rowhelpers is due to how SQLPage processes templates internally.In SQLPage the template rendering process involves splitting templates into three parts:
When SQLPage encounters an
each_rowhelper, it splits the template at that point using thesplit_templatefunction. This function extracts the content inside theeach_rowblock into a separate template (list_content), with everything before it going intobefore_listand everything after intoafter_list.The problem occurs because inline partials defined with
{{#*inline "name"}}...{{/inline}}are registered in the Handlebars registry during the initial template parsing. However, when the template is split, these inline partial definitions remain in thebefore_listsection, but thelist_contenttemplate (which contains youreach_rowcontent) becomes a separate template context that doesn't have access to those inline partials.In the
render_itemmethod ofSplitTemplateRenderer, when it tries to render each row, it's using the isolatedlist_contenttemplate which can't see the inline partials defined in the parent template.This is why you're seeing the "Partial not found item" error - the
{{> item }}reference inside youreach_rowblock is looking for a partial that isn't accessible from that context.Possible workarounds:
each_rowblock instead of a partial#each_rowThis is a limitation of how SQLPage processes templates to support its streaming row-by-row rendering model, which is different from standard Handlebars processing.
mesr commentedon Mar 7, 2025
Thank you @lovasoa for this detailed answer. This is very useful information indeed. Workaround 1 is not applicable to our use case, as it would lead to a lot of hard-to-maintain duplication of code. Workaround 2, even though not ideal, is a workable solution. So, thanks again and keep up the good work!
81reap commentedon Oct 29, 2026
I think this is still an issue
reproduction
On commit 616df27:
nix run .#reproduce -- repro_846 postgres v0.33.0 v0.47.0 treefix(templates) :: let `each_row` call inline partials
fix(templates) :: let `each_row` call inline partials (sqlpage#1580)