Can someone explain render_region to me.

View: New views
3 Messages — Rating Filter:   Alert me  

Can someone explain render_region to me.

by crankin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I love radiant, but trying to find up to date and accurate
documentation is a not easy. I'm trying to figure out how to use the
render_region helper. I see it in views, and in some extensions, but
if I ever try to include it in any of my extensions I'll get an error
like:

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

For example

mypage.html.haml

= render_region :top

%p
  This will crash


mypage2.html.haml

%p
  This works just fine.


What are regions, where are they, what is the benefit of using
render_region? I see it used for tables, etc. What is the point? And
how come it breaks on me? And not other extensions? Should I require
or include something?

--~--~---------~--~----~------------~-------~--~----~
Radiant CMS Dev Mailing List
Post:        radiantcms-dev@...
Unsubscribe: radiantcms-dev-unsubscribe@...
Group Site:  http://groups.google.com/group/radiantcms-dev/
-~----------~----~----~----~------~----~------~--~---


Re: Can someone explain render_region to me.

by Sean Cribbs-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


render_region is not really intended to be a public API.  What it does
is allow extensions to add view partials to existing spots inside the
stock admin UI, and thus customizing them.  For example, if I wanted to
add a partial to the top of the Pages listing/sitemap, I would put this
line in my extension:

admin.pages.index.add :top, "my_partial"

Then the 'render_region :top' call inside
app/views/admin/pages/index.html.haml would render my partial at that
spot.  What is key to note here is that Radiant internally populates the
'admin' object with the appropriate data structures to expose the above
API.  If you want to provide an extensible view to other extensions, you
might find the 'dashboard' or 'help' extensions illustrative in their
implementations of this API.

Sean

crankin wrote:

> I love radiant, but trying to find up to date and accurate
> documentation is a not easy. I'm trying to figure out how to use the
> render_region helper. I see it in views, and in some extensions, but
> if I ever try to include it in any of my extensions I'll get an error
> like:
>
> You have a nil object when you didn't expect it!
> You might have expected an instance of ActiveRecord::Base.
> The error occurred while evaluating nil.[]
>
> For example
>
> mypage.html.haml
>
> = render_region :top
>
> %p
>   This will crash
>
>
> mypage2.html.haml
>
> %p
>   This works just fine.
>
>
> What are regions, where are they, what is the benefit of using
> render_region? I see it used for tables, etc. What is the point? And
> how come it breaks on me? And not other extensions? Should I require
> or include something?
>
> >
>
>  


--~--~---------~--~----~------------~-------~--~----~
Radiant CMS Dev Mailing List
Post:        radiantcms-dev@...
Unsubscribe: radiantcms-dev-unsubscribe@...
Group Site:  http://groups.google.com/group/radiantcms-dev/
-~----------~----~----~----~------~----~------~--~---


Re: Can someone explain render_region to me.

by crankin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok that makes alot of sense.

Thanks,

Chris

On Mon, Nov 2, 2009 at 8:22 PM, Sean Cribbs <seancribbs@...> wrote:

render_region is not really intended to be a public API.  What it does
is allow extensions to add view partials to existing spots inside the
stock admin UI, and thus customizing them.  For example, if I wanted to
add a partial to the top of the Pages listing/sitemap, I would put this
line in my extension:

admin.pages.index.add :top, "my_partial"

Then the 'render_region :top' call inside
app/views/admin/pages/index.html.haml would render my partial at that
spot.  What is key to note here is that Radiant internally populates the
'admin' object with the appropriate data structures to expose the above
API.  If you want to provide an extensible view to other extensions, you
might find the 'dashboard' or 'help' extensions illustrative in their
implementations of this API.

Sean

crankin wrote:
> I love radiant, but trying to find up to date and accurate
> documentation is a not easy. I'm trying to figure out how to use the
> render_region helper. I see it in views, and in some extensions, but
> if I ever try to include it in any of my extensions I'll get an error
> like:
>
> You have a nil object when you didn't expect it!
> You might have expected an instance of ActiveRecord::Base.
> The error occurred while evaluating nil.[]
>
> For example
>
> mypage.html.haml
>
> = render_region :top
>
> %p
>   This will crash
>
>
> mypage2.html.haml
>
> %p
>   This works just fine.
>
>
> What are regions, where are they, what is the benefit of using
> render_region? I see it used for tables, etc. What is the point? And
> how come it breaks on me? And not other extensions? Should I require
> or include something?
>
> >
>
>





--~--~---------~--~----~------------~-------~--~----~
Radiant CMS Dev Mailing List
Post:        radiantcms-dev@...
Unsubscribe: radiantcms-dev-unsubscribe@...
Group Site:  http://groups.google.com/group/radiantcms-dev/

-~----------~----~----~----~------~----~------~--~---