Class: Weft::Defaults::NotFoundComponent

Inherits:
Component
  • Object
show all
Defined in:
lib/weft/defaults/not_found_component.rb

Overview

Gem-default component rendered when a routing miss falls through to the Weft::Page chain (C4) or when an action raises Weft::NotFound and no user recovers entry matches.

Constant Summary collapse

STYLE =
"padding:1rem; border:1px solid #cbd5e1; border-radius:6px; " \
"background:#f8fafc; color:#0f172a; font-size:0.875rem"
MONO_STYLE =
"margin-top:0.5rem; font-family:monospace; font-size:0.8rem; color:#475569"

Instance Attribute Summary

Attributes included from Weft::DSL::Attributes

#attrs

Instance Method Summary collapse

Methods inherited from Component

inferred_routable?, inherited, render, resolved_component_path, weft_id_for, #weft_url

Methods included from Registry::Eligibility

#abstract!, #routable!, #routable?, #stale?

Methods included from Context::Interception

#insert_tag

Methods included from Weft::DSL::Containers

behavior_for, included

Methods included from Weft::DSL::Actions

included

Methods included from Weft::DSL::Updates

included

Methods included from Weft::DSL::Inclusions

included

Methods included from Weft::DSL::Triggers

included

Methods included from Weft::DSL::Recoveries

included

Methods included from Weft::DSL::Attributes

included

Instance Method Details

#build(attributes = {}) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/weft/defaults/not_found_component.rb', line 22

def build(attributes = {})
  super
  add_class "weft-not-found"
  set_attribute "style", STYLE

  div(style: "font-weight:600") { text_node "Not found" }
  render_verbose if Weft.configuration.verbose_error_pages && @attrs.request_path
end

#weft_idObject

Preserve the failing component's DOM identity when the Router injected :component_id. Otherwise fall back to the class-derived default.



33
34
35
# File 'lib/weft/defaults/not_found_component.rb', line 33

def weft_id
  @attrs.component_id || super
end