Integrating Action View Helpers
Using Rails view helpers (https://api.rubyonrails.org/classes/ActionView/Helpers.html) in components, pages and layouts is supported when using the approaches shown below;

Helpers without a block

Simple Action View helpers working without a block, can easily be integrated in a Matestack class response by calling plain:
1
def response
2
plain t("my.locale")
3
# ...
4
plain link_to "Show", post_path(@post)
5
# ...
6
plain my_own_view_helper_method
7
# ...
8
plain any_method_returning_a_string
9
end
Copied!

Helpers yielding a block

If you want to use a helper like form_for you have to follow following approach:
1
def response
2
# ...
3
plain do # <-- add this
4
form_with url: "/some_path" do |f|
5
matestack_to_s do # <-- add this, which converst following block to a string
6
plain f.text_field :foo # <-- call plain here again
7
br
8
div class: "some-input-wrapper" do
9
plain f.text_field :bar
10
end
11
br
12
plain f.submit
13
end
14
end
15
end
16
# ...
17
plain do
18
link_to root_path do
19
matestack_to_s do
20
div class: "some-link-wrapper" do
21
plain "foo from block"
22
end
23
end
24
end
25
end
26
# ...
27
# Code below will not work!
28
plain link_to root_path do
29
matestack_to_s do
30
div class: "some-link-wrapper" do
31
plain "foo from block"
32
end
33
end
34
end
35
end
Copied!
A component needs to be called in context of a controller (with included Matestack::Ui::Core::Helper), which is true when you're calling components from Rails views or on Matestack Pages/Layouts (which are themselves called by a controller normally).
When calling a component in isolation (which is possible), the view helpers might not work properly, especially when (implicitly) requiring a request object!
We're currently working on an improved way to integrate ActionView Helpers which will enable removing the plain calls from your code.