Improve error messaging when using `<#slot />` in template via `embed_sface/1` macro
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Elixir
- Estrellas
- 2.1k
- Forks
- 146
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de surface-ui/surface
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
surface-ui/surface#634 · 1 reacción ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
surface-ui/surface#770 ·
-
Website is downAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
surface-ui/surface#768 · 4 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
surface-ui/surface#762 · 2 comentarios · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
surface-ui/surface#759 · 1 reacción ·
Todos los issues de surface-ui/surface
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
electric-sql/electric#4830 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
dependabot/dependabot-core#16547 ·
Los mantenedores suelen responder en 1 día
-
github_actions
Dificultad 1/5 Menos de una hora Aptitud para principiantes 94/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
team-alembic/clarity#146 ·