Class: Views::Html

Inherits:
Object
  • Object
show all
Includes:
HtmlSlice
Defined in:
lib/roda/templates/front-end/app/views/html.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(t) ⇒ Html

Returns a new instance of Html.



8
9
10
11
# File 'lib/roda/templates/front-end/app/views/html.rb', line 8

def initialize(t)
  @t = t
  @foo = Views::Foo::Html.new
end

Instance Attribute Details

#fooObject (readonly)

for more component classes



6
7
8
# File 'lib/roda/templates/front-end/app/views/html.rb', line 6

def foo
  @foo
end

Instance Method Details

#css_entrypoint_tag(entrypoint) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/roda/templates/front-end/app/views/html.rb', line 21

def css_entrypoint_tag(entrypoint)
  if Config.not_production?
    "<link rel=\"stylesheet\" href=\"/public/assets/#{entrypoint}.css\" />"
  else
    "<link rel=\"stylesheet\" href=\"#{Config.get[:assets][:host]}/#{Config.get[:assets][:manifest]["#{entrypoint}.css"]}\" />"
  end
end

#js_entrypoint_tag(entrypoint) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/roda/templates/front-end/app/views/html.rb', line 13

def js_entrypoint_tag(entrypoint)
  if Config.not_production?
    "<script src=\"/public/assets/#{entrypoint}.js\" defer></script>"
  else
    "<script src=\"#{Config.get[:assets][:host]}/#{Config.get[:assets][:manifest]["#{entrypoint}.js"]}\" defer></script>"
  end
end


29
30
31
32
33
34
35
36
# File 'lib/roda/templates/front-end/app/views/html.rb', line 29

def navbar
  html_slice do
    div class: "navbar" do
      a "home", href: "/"
      a "foo/bar", href: "/foo/bar"
    end
  end
end