Forum: Ruby on Rails RE: how to include an html file?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Berger, Daniel (Guest)
on 2006-02-21 20:38
(Received via mailing list)
> Other then that though you could simple open the file and
> spit the results manually. So, a simple helper function:
> def include_page(file_name)
>   result = ""
>, "r") { |f| result << }
>   result
> end

That can be shortened to:

def include_page(file_name)


Cb610750ee94ca103aef4b2dc7b1b768?d=identicon&s=25 Nick Stuart (Guest)
on 2006-02-21 20:54
(Received via mailing list)
Of course it can! :)
Thanks for that, there seems to always be a 'shorter' way in ruby!
39045f22049b1db3e3dd08c3bffac17e?d=identicon&s=25 Filip Godsmurf (godsmurf)
on 2006-02-21 21:01
Thanx guys!
8e44c65ac5b896da534ef2440121c953?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-02-22 05:23
(Received via mailing list)

<%= render :file => '/absolute/full/path/to/file' %>

And that will interpret any erb thats in the file as well.

This topic is locked and can not be replied to.