# Render layout on the fly

**URL:** <https://www.ruby-forum.com/t/render-layout-on-the-fly/60978>\
**Category:** Rails\
**Created:** [May 19, 2006, 12:26am UTC](https://www.ruby-forum.com/t/render-layout-on-the-fly/60978 "2006-05-19T00:26:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franz\_Bettag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/41988e/32.png) [@Franz\_Bettag](https://www.ruby-forum.com/u/Franz_Bettag)\
**Post date:** [May 19, 2006, 12:26am UTC](https://www.ruby-forum.com/t/render-layout-on-the-fly/60978/1 "2006-05-19T00:26:21Z")

</div>

Hi guys,

i was wondering if there is any possibility to render a layout on the  
fly instead of putting it into the layouts/ folder. Any ideas?

---

<div class="post-metadata">

**Author:** ![Franz\_Bettag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/41988e/32.png) [@Franz\_Bettag](https://www.ruby-forum.com/u/Franz_Bettag)\
**Post date:** [May 19, 2006, 1:16am UTC](https://www.ruby-forum.com/t/render-layout-on-the-fly/60978/2 "2006-05-19T01:16:17Z")

</div>

Franz Bettag wrote:

> Hi guys,
> 
> i was wondering if there is any possibility to render a layout on the  
> fly instead of putting it into the layouts/ folder. Any ideas?

Not sure what you mean. Layouts are rendered just like any rhtml file.

---

<div class="post-metadata">

**Author:** ![Franz\_Bettag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/41988e/32.png) [@Franz\_Bettag](https://www.ruby-forum.com/u/Franz_Bettag)\
**Post date:** [May 19, 2006, 9:41am UTC](https://www.ruby-forum.com/t/render-layout-on-the-fly/60978/3 "2006-05-19T09:41:54Z")

</div>

Alex W. wrote:

> Franz Bettag wrote:
> 
> > Hi guys,
> > 
> > i was wondering if there is any possibility to render a layout on the  
> > fly instead of putting it into the layouts/ folder. Any ideas?
> 
> Not sure what you mean. Layouts are rendered just like any rhtml file.

Yeah but normal .rhtml files have to be in the layouts folder. I want to  
load the layout from another website everytime the shop gets called. So  
not store them locally. I know this i quite bw consuming on sites with  
many hits but my customer want’s it that way 🙂

---

<div class="post-metadata">

**Author:** ![Franz\_Bettag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/41988e/32.png) [@Franz\_Bettag](https://www.ruby-forum.com/u/Franz_Bettag)\
**Post date:** [May 19, 2006, 4:57pm UTC](https://www.ruby-forum.com/t/render-layout-on-the-fly/60978/4 "2006-05-19T16:57:37Z")

</div>

Franz Bettag wrote:

> Alex W. wrote:
> 
> > Franz Bettag wrote:
> > 
> > > Hi guys,
> > > 
> > > i was wondering if there is any possibility to render a layout on the  
> > > fly instead of putting it into the layouts/ folder. Any ideas?
> > 
> > Not sure what you mean. Layouts are rendered just like any rhtml file.
> 
> Yeah but normal .rhtml files have to be in the layouts folder. I want to  
> load the layout from another website everytime the shop gets called. So  
> not store them locally. I know this i quite bw consuming on sites with  
> many hits but my customer want’s it that way 🙂

I took a look at the Rails API and found these examples:

# Renders the template located at the absolute filesystem path

render :file =\> “/path/to/some/template.rhtml”  
render :file =\> “c:/path/to/some/template.rhtml”

# Renders a template within the current layout, and with a 404 status

code  
render :file =\> “/path/to/some/template.rhtml”, :layout =\> true,  
:status =\> 404  
render :file =\> “c:/path/to/some/template.rhtml”, :layout =\> true,  
:status =\> 404

# Renders a template relative to the template root and chooses the

proper file extension  
render :file =\> “some/template”, :use\_full\_path =\> true

and

# Renders the template located in

[TEMPLATE\_ROOT]/weblog/show.r(html|xml) (in Rails,  
app/views/weblog/show.rhtml)  
render :template =\> “weblog/show”
