Closing HTML Tags, or Containing HTML

How are you gentlemen?

I have a view where I need to render some HTML stored in site.html_code

<%= site.html_code %>

The problem is, when I do that, it changes all the links on the rest of
the page that are pulled in by layout.

So instead of my “Home” link pointing to “/main/index”, it’ll now point
to “URL_FROM_site.html_code/http://localhost:3000/main/index”.

I figure I can go in and change the navigation links in the layout, but
is there a way to just “contain” the HTML from site.html_code so that it
doesn’t affect the rest of the page.

Joe P. wrote:

is there a way to just “contain” the HTML from site.html_code so that it
doesn’t affect the rest of the page.

How are you displaying the views in your layout? Regardless of what you
are rendering in the layout, the links shouldn’t be changing. I have
views with links in them that don’t randomly change. Sounds like you
might have some kind of HTML formatting issue. In my views I render the
content by:

<%=@content_for_layout%>

Are you doing something similar? If html_code is a partial you want to
say:

<%= render :partial => ‘html_code’ %>

How are you displaying the views in your layout? Regardless of what you
are rendering in the layout, the links shouldn’t be changing. I have
views with links in them that don’t randomly change. Sounds like you
might have some kind of HTML formatting issue. In my views I render the
content by:

<%=@content_for_layout%>

Are you doing something similar? If html_code is a partial you want to
say:

<%= render :partial => ‘html_code’ %>

I’m rendering the content in the layout like this:
<%= yield -%>

When I render site.html_code, html_code is a column in the Sites table
that holds the HTML of that Site. Is there any way to “encapsulate” the
rendered HTML code so that it can’t affect the rest of the page?

I’m rendering the content in the layout like this:
<%= yield -%>

When I render site.html_code, html_code is a column in the Sites table
that holds the HTML of that Site. Is there any way to “encapsulate” the
rendered HTML code so that it can’t affect the rest of the page?

I render “html_code” like this:
<%= @site.html_code %>

Somehow, it is changing the nav-links in my layout. Might it have
something to do that the “html_code” is all the HTML from a Wayback
result for the site?

Frederick C. wrote:

It could conceivably make the browser do all sorts of things if what
you end up with is invalid html (unclosed tags etc…) or html
designed for a different doctype than your page. If it’s just all the
html from wayback (including for example the head or body tags) then
it’s going to be very yucky. sticking it in a frame/iframe might be
workable.

Fred

Thanks, it looks like iframes are the solution for me.

Only thing is, I’m having trouble getting it to just put @site.html_code
inside the iframe. Somehow, it keeps thinking that @site is a nil
object.

Hmm, time to try to find out how to do this. If anyone has any ideas, I
am all ears.

Okay, I figured it out. “src” has to be a URL, so I just did this.

Then in the controller:
def show_site_html_code
@site = Site.find_by_id(params[:site_id])
render(:layout => false)
end

Hopefully this can help someone else who wants to know how to use
iframes with rails like this.

Good thread to read right here:
http://www.ruby-forum.com/topic/144196#new

On 5 Sep 2008, at 16:59, Joe P. wrote:

I render “html_code” like this:
<%= @site.html_code %>

Somehow, it is changing the nav-links in my layout. Might it have
something to do that the “html_code” is all the HTML from a Wayback
result for the site?

It could conceivably make the browser do all sorts of things if what
you end up with is invalid html (unclosed tags etc…) or html
designed for a different doctype than your page. If it’s just all the
html from wayback (including for example the head or body tags) then
it’s going to be very yucky. sticking it in a frame/iframe might be
workable.

Fred