Add compatibility for content_for #984

Closed
gschammah opened this Issue Feb 7, 2012 · 2 comments

Comments

Projects
None yet
3 participants

There are many gems that make use of

content_for :head do
  ...
end

But those gems cannot be used in active admin since we dont have any layout to put the yield :head. It would be nice if Arbre can be compatible with predefined placeholders for some code (e.g. content_for(:head), content_for(:footer), etc).

The way I am injecting code to the layout head is doing @head << div { ... } inside my admin partials. This works fine, but I cannot access the @head variable from outside my views, for example in a sidebar declaration. I am using the gmaps4rails gem and tried to insert a map into a sidebar, but couldnt inject the dinamically generated js into the layout head.

gregbell was assigned Feb 23, 2012

Contributor

shell commented Sep 19, 2012

I have done investigation on this with my coworkers, and it seems like you can not use content_for directly because of how active_admin works. Build of the page and layout is running before you run partials that was declared in active_admin dsl.

In new version 0.5.0 there is workaround for that. Called ActiveAdmin Components. You can take advantage of that.

ActiveAdmin.setup do |config|
  config.view_factory.footer = MyFooter
end
class MyFooter < ActiveAdmin::Component
  def build?
    super(id: "footer")
    para "Copyright #{Date.today.year} Reverb Media Group"
  end
end

You can register custom javascripts and stylesheets in the AA initializer file as well:

    config.register_javascript 'my_javascript.js' 

Hope this helps.

Contributor

gregbell commented Sep 26, 2012

Currently isn't supported but may be very helpful.

@shell points out a couple of great ways to get around this right now. If neither if these work for you, we would accept a pull request to implement this kind of functionality :)

gregbell closed this Sep 26, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment