Class: Lively::Pages::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/lively/pages/index.rb

Overview

Represents the main index page for a Lively application.

This class renders the initial HTML page that users see when they visit a Lively application. It uses an XRB template to generate the page structure and embeds the Live view component for dynamic content.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: "Lively", body: nil) ⇒ Index

Initialize a new index page.



21
22
23
24
25
26
27
# File 'lib/lively/pages/index.rb', line 21

def initialize(title: "Lively", body: nil)
  @title = title
  @body = body
  
  path = File.expand_path("index.xrb", __dir__)
  @template = XRB::Template.load_file(path)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



33
34
35
# File 'lib/lively/pages/index.rb', line 33

def body
  @body
end

#templateObject (readonly)

Returns the value of attribute template.



36
37
38
# File 'lib/lively/pages/index.rb', line 36

def template
  @template
end

#The title of the page.(titleofthepage.) ⇒ Object (readonly)



30
# File 'lib/lively/pages/index.rb', line 30

attr :title

#titleObject (readonly)

Returns the value of attribute title.



30
31
32
# File 'lib/lively/pages/index.rb', line 30

def title
  @title
end

Instance Method Details

#callObject

Render this page to a string.



40
41
42
# File 'lib/lively/pages/index.rb', line 40

def call
  @template.to_string(self)
end

#The body content of the page.=(bodycontentofthepage. = (value)) ⇒ Object



33
# File 'lib/lively/pages/index.rb', line 33

attr :body

#The XRB template for rendering the page.=(XRBtemplate) ⇒ Object



36
# File 'lib/lively/pages/index.rb', line 36

attr :template