Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messaging when using <#slot /> in template via embed_sface/1 macro #699

Open
harmon25 opened this issue Jul 18, 2023 · 0 comments

Comments

@harmon25
Copy link
Contributor

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

@harmon25 harmon25 changed the title Improve messaging when using <#slot /> in template via embed_sface/1 macro Improve error messaging when using <#slot /> in template via embed_sface/1 macro Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant