Rails gives you the tools to do much of this already.
For example, this:
html_slice :stuff do
h1 'hello world' # @html_slice[:default] << '<h1>hello world</h1>'
text # @html_slice[:default] << '<p>Lorem ipsum dolor sit amet</p>'
div do
_ '<b> some raw html </b>'
end
end
Could be written in a helper like this:
safe_join([
tag.h1('Hello world'),
tag.p('Lorem ipsum dolor sit amet'),
tag.div(<<~RAW.html_safe)
<b>some raw html</b>
RAW
])
For example, this:
Could be written in a helper like this: