# Render partial as full template

**URL:** <https://www.ruby-forum.com/t/render-partial-as-full-template/133811>\
**Category:** Rails\
**Created:** [April 3, 2008, 9:48pm UTC](https://www.ruby-forum.com/t/render-partial-as-full-template/133811 "2008-04-03T21:48:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [April 3, 2008, 9:48pm UTC](https://www.ruby-forum.com/t/render-partial-as-full-template/133811/1 "2008-04-03T21:48:20Z")

</div>

I would like to render a partial template as a full template. The reason  
is that the partial contains content normally displayed via xhr and I  
want to display it also if my app degrades.

The way I do this now is to have a full template containing one line  
like  
the below, but I’d rather do away with it because it seems a pointless  
one line file:-  
/app/views/my\_controller/my\_full\_template.html.erb:  
\<%= render :partial =\> “my\_partial\_template” %\>

I call this from the controller like this:  
render :action =\> :my\_full\_template

What I’d like to do is render “my\_partial\_template” directly from the  
controller but render it as a full template so that it is displayed  
within my application layout.

The following is one solution but I think it isn’t very elegant  
render :template =\> “my\_controller/\_my\_partial\_template)”

Is there a better way to achieve this?

Many thanks.

---

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [April 3, 2008, 9:56pm UTC](https://www.ruby-forum.com/t/render-partial-as-full-template/133811/2 "2008-04-03T21:56:41Z")

</div>

On 3 Apr 2008, at 20:48, John L. wrote:

> What I’d like to do is render “my\_partial\_template” directly from the  
> controller but render it as a full template so that it is displayed  
> within my application layout.
> 
> The following is one solution but I think it isn’t very elegant  
> render :template =\> “my\_controller/\_my\_partial\_template)”

You can just call render :partial =\> ‘…’ in your controller.

Fred

---

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [April 3, 2008, 11:56pm UTC](https://www.ruby-forum.com/t/render-partial-as-full-template/133811/3 "2008-04-03T23:56:16Z")

</div>

Frederick C. wrote:

> You can just call render :partial =\> ‘…’ in your controller.

Fred, hi. You can indeed do that but that renders JUST the partial, it  
does not render the whole page layout like rendering a full template  
does.

---

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [April 4, 2008, 12:25am UTC](https://www.ruby-forum.com/t/render-partial-as-full-template/133811/4 "2008-04-04T00:25:55Z")

</div>

John L. wrote:

> Frederick C. wrote:
> 
> > You can just call render :partial =\> ‘…’ in your controller.
> 
> Fred, hi. You can indeed do that but that renders JUST the partial, it  
> does not render the whole page layout like rendering a full template  
> does.

render :partial =\> ‘…’, :layout =\> true

maybe?

---

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [April 4, 2008, 8:23am UTC](https://www.ruby-forum.com/t/render-partial-as-full-template/133811/5 "2008-04-04T08:23:02Z")

</div>

Alex W. wrote:

> render :partial =\> ‘…’, :layout =\> true
> 
> maybe?

Yes, that’s it! I wasn’t familiar with :layout =\> true.

Thanks Alex!
