Skip to content

Including hoshi from a outside class #2

@madhermit

Description

@madhermit

Hi @pete

I have an outside class that has a to_hoshi method. How can I have that method interpolated into the Hoshi output of my view class in Watts. Here is an example:

require "hoshi"

class Foo < Hoshi::View :html5
  def show
    h1 "inside Foo#show"
    Bar.new.inclusion
    inclusion
  end

  def inclusion
    h2 "inside Foo#inclusion"
  end
end

class Bar
  def inclusion
    h2 "inside Bar#inclusion"
  end
end

puts Foo.new.show

Desired output:

<h1>inside Foo#show</h1>
<h2>inside Bar#inclusion</h2>
<h2>inside Foo#inclusion</h2>

Current output:
inclusion': undefined method 'h2' for #<Bar:0x0055dafd73e988> (NoMethodError)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions