Open sebyx07 opened 2 years ago
i came with a smth:
module MatestackCoreHelper
[
ActionView::Helpers::UrlHelper.instance_methods(false),
ActionView::Helpers::AssetTagHelper.instance_methods(false),
].flatten.each do |rails_view_method|
define_method rails_view_method do |*args, **opts, &block|
if block
args.unshift(matestack_to_s { block.call })
end
plain { super(*args, **opts) }
end
end
%i[
form_with form_for content_tag
].each do |rails_view_method|
define_method rails_view_method do |*args, **opts, &block|
plain do
super(*args, **opts) do |form|
matestack_to_s do
block.call(PlainWrapper.new(self, form))
end
end
end
end
end
class PlainWrapper
def initialize(ctx, form)
@ctx = ctx; @form = form
end
private def method_missing(method, *args, **opts, &block)
return super unless @form.respond_to?(method)
@ctx.plain @form.send(method, *args, **opts, &block)
end
end
end
now the example above works w/o calling plain explicitly
I also tried with simple_form and it works, just had to add simple_form_for
to call PlainWrapper
would be nice if matestack would support rails view tags by default
I know matestack has it's own form way, but still