arbre
arbre copied to clipboard
Nested link generation
Hello I try to do something like
user_with_link = link_to(user.email, [:admin, user])
h3 [user_with_link, v.event, l(v.created_at, format: :short)].join(', ')
and fails, becourse of geting "safe" first tag output and link writes in compile html like
<a href="/admin/admin_users/1">[email protected]</a>, create, 29 feb., 00:46
As you understand, i just want to have h3 tag, where part of it will be link.
I try out code like raw( "<h3>" + [user_with_link, v.event, l(v.created_at, format: :short)].join(', ') + "</h3>") but it was not good also.
h3 tad does not accept the block, so, i can not push sew different lines of code.
I tryed out to use text_node, but it also escape the output, outerway i loose the context.
How I can provide propper output in Arbre way?
Thank you
This works for me:
include ActionView::Helpers::UrlHelper
Arbre::Context.new{
h3 link_to('foo', 'bar') + ', something, else'
}
=> <h3><a href="bar">foo</a>, something, else</h3>
Thank you for your answer, but is no good also
I need to mansion, that I use Arbre gem as the part of ActiveAdmin, and I just want to customize some view in right way
so, I need not include UrlHelper
this is pry output
[1] pry(#<ActiveAdmin::Views::Pages::Show>)> h3 [user_with_link, v.event, I18n.l(v.created_at, format: :short)].join(", ")
=> <h3><a href="/admin/admin_users/1">[email protected]</a>, update, 29 февр., 02:06</h3>
[2] pry(#<ActiveAdmin::Views::Pages::Show>)> Arbre::Context.new{
[2] pry(#<ActiveAdmin::Views::Pages::Show>)* h3 [user_with_link, v.event, I18n.l(v.created_at, format: :short)].join(", ")
[2] pry(#<ActiveAdmin::Views::Pages::Show>)* }
=> <h3><a href="/admin/admin_users/1">[email protected]</a>, update, 29 февр., 02:06</h3>
[3] pry(#<ActiveAdmin::Views::Pages::Show>)>
As you can see it is the same output
Try using the syntax that @seanlinsley used, rather than wrapping your parameters in an array.
I tried the following and it rendered fine:
ActiveAdmin.register_page "Test" do
content do
h3 link_to(AdminUser.find(1).email, admin_admin_user_url(1)) + ', more text'
end
end
Rendered html:
<h3><a href="/admin/admin_users/1">[email protected]</a>, more text</h3>
It is better to make it in ApplicationController
class ApplicationController < ActionController::Base include ActionView::Helpers::UrlHelper end