Improve error messaging when using `<#slot />` in template via `embed_sface/1` macro
まだ誰も着手していません。
評価
調査の方向性
Reproduce the failure by updating test/surface_test_embed_sface.sface with the shown template. Then inspect lib/surface/compiler/eex_engine.ex around build_render_slot_context_expr/3 and the embed_sface expansion path. Done means the misuse produces a clear diagnostic or the documented alternative is clearly surfaced, with the reproduction covered by a test.
索引モデルが issue の本文から書いたものです。
説明
Maybe it was because I was programming when I should have been in bed - but I got stumped by this. It took a bit of reflection to realize I needed to use {@inner_content} instead of default slot with embed_sface/1 and .sface templates.
Using <#slot /> here resulted in an ArgumentError like this:
(ArgumentError) errors were found at the given arguments:
* 2nd argument: not a tuple
:erlang.element(1, nil)
(surface 0.11.0) lib/surface/compiler/eex_engine.ex:1214: Surface.Compiler.EExEngine.build_render_slot_context_expr/3
(surface 0.11.0) lib/surface/compiler/eex_engine.ex:194: Surface.Compiler.EExEngine.to_expression/3
(surface 0.11.0) lib/surface/compiler/eex_engine.ex:70: Surface.Compiler.EExEngine.generate_buffer/3
(surface 0.11.0) lib/surface/compiler/eex_engine.ex:35: Surface.Compiler.EExEngine.translate/2
(surface 0.11.0) expanding macro: Surface.embed_sface/1
Some better messaging would help a lot here - or maybe just a clear callout in the docs?
How to reproduce it
Updating the test/surface_test_embed_sface.sface to look like this can reproduce:
<div>embed_sface</div>
<#slot />
The behavior you expected
I expected <#slot /> to work, and the resulting ArgumentError was of little assistance.
Here is a suggestion:
error: Trying to use `<#slot />` in a deadview/template, use `{@innter_content}` instead.
Your Environment
Surface: v0.11.0
LiveView: v019.4
Elixir: v1.15.3
- 主要言語
- Elixir
- スター
- 2.1k
- フォーク
- 146
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
surface-ui/surface のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
surface-ui/surface#634 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
surface-ui/surface#770 ·
-
Website is downオープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
surface-ui/surface#768 · コメント 4 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
surface-ui/surface#762 · コメント 2 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
surface-ui/surface#759 · リアクション 1 件 ·
surface-ui/surface の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
electric-sql/electric#4830 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
Gradle release-date fallback accepts `Last-Modified` from non-2xx responses, so `cooldown` lets brand-new plugin versions through対応中かも @v-robaiken が 1 日前に担当しました。 オープンL: java:gradle T: bug 🐞
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dependabot/dependabot-core#16547 · リアクション 1 件 · 担当者 2 名 ·
メンテナーはふだん 1 日以内に返信
-
github_actions
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
メンテナーはふだん 1 日以内に返信