Improve error messaging when using `<#slot />` in template via `embed_sface/1` macro
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Elixir
- Stelle
- 2.1k
- Fork
- 146
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di surface-ui/surface
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
surface-ui/surface#634 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
surface-ui/surface#770 ·
-
Website is downAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
surface-ui/surface#768 · 4 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
surface-ui/surface#762 · 2 commenti · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
surface-ui/surface#759 · 1 reazione ·
Tutte le issue di surface-ui/surface
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
electric-sql/electric#4830 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Gradle release-date fallback accepts `Last-Modified` from non-2xx responses, so `cooldown` lets brand-new plugin versions throughForse già presa @v-robaiken l’ha presa 1 giorno fa. ApertaL: java:gradle T: bug 🐞
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
dependabot/dependabot-core#16547 · 1 reazione · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
github_actions
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 94/100
I maintainer di solito rispondono entro 1 giorno