How about supporting a theoretical code like this?
class Page
include Paggio::HTML
def initialize(title, content)
@title = title
@content = content
end
def to_html
html do
head do
title @title
end
body do
@content
end
end
end
end
puts Page.new("foo", "bar").to_html
What I done here, is include a mixin, which moves all HTML tag methods into the class context. Sure, we would need to be extra careful not to override those. This way, it would encourage object-oriented programming with no problems related to instance_eval use.
This is how https://github.com/erector/erector works, afaik.