Skip to content

Improve error message when attributes have been defined after an embedded template #3812

Description

@camilohollanda

LiveView generated application

defmodule MyappWeb.Layouts do
  @moduledoc """
  This module holds different layouts used by your application.

  See the `layouts` directory for all templates available.
  The "root" layout is a skeleton rendered as part of the
  application router. The "app" layout is rendered as component
  in regular views and live views.
  """
  use MyappWeb, :html

  embed_templates "layouts/*"

  @doc """
  Renders the app layout

  ## Examples

      <Layouts.app flash={@flash}>
        <h1>Content</h1>
      </Layout.app>

  """
  attr :flash, :map, required: true, doc: "the map of flash messages"

  attr :current_scope, :map,
    default: nil,
    doc: "the current [scope](https://hexdocs.pm/phoenix/scopes.html)"

  slot :inner_block, required: true

  def app(assigns) do
    ~H"""
    <header class="navbar px-4 sm:px-6 lg:px-8">
== Compilation error in file lib/myapp_web/components/layouts.ex ==
** (CompileError) lib/myapp_web/components/layouts.ex:24: attributes must be defined before the first function clause at line 12

    (phoenix_live_view 1.0.9) lib/phoenix_component/declarative.ex:557: Phoenix.Component.Declarative.compile_error!/3
    (phoenix_live_view 1.0.9) lib/phoenix_component/declarative.ex:733: Phoenix.Component.Declarative.register_component!/4
    (phoenix_live_view 1.0.9) expanding macro: Phoenix.Component.Declarative.__pattern__!/2
    lib/myapp_web/components/layouts.ex:32: MyappWeb.Layouts.app/1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions