[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Source a javascript and stylesheet into rhtml file

Tim Trampedach

9/15/2007 4:47:00 AM

Hi all,

I'm trying to do a quick dump of a javascript and style sheet located in
their respective /public directories into an rhtml file. I want to
include the entire text of the file in my rhtml file. How do I do this
quickly and efficiently? In PHP there's readfile, but I can't figure out
an equivalent call in ruby.

Thanks so much in advance!

Tim
--
Posted via http://www.ruby-....

4 Answers

Phlip

9/15/2007 5:10:00 AM

0

Tim Trampedach wrote in message ne
> I'm trying to do a quick dump of a javascript and style sheet located in
> their respective /public directories into an rhtml file.

<%=h File.read(RAILS_ROOT + '/public/javascript/my_source.js') %>

This is half introductory Ruby and half introductory Rails, so one might
consider reading a little of the excellent books on these subjects, offline,
for a while!

--
Phlip


James Britt

9/15/2007 5:25:00 AM

0

Phlip wrote:
> Tim Trampedach wrote in message ne>
>> I'm trying to do a quick dump of a javascript and style sheet located in
>> their respective /public directories into an rhtml file.
>
> <%=h File.read(RAILS_ROOT + '/public/javascript/my_source.js') %>
>
> This is half introductory Ruby and half introductory Rails, so one might
> consider reading a little of the excellent books on these subjects,
> offline, for a while!



Rails questions are better directed to Rails mailing list, where you'll
get better, faster, information.


--
James Britt

"Judge a man by his questions, rather than his answers."
- Voltaire

Gregory Seidman

9/15/2007 2:36:00 PM

0

On Sat, Sep 15, 2007 at 02:24:59PM +0900, James Britt wrote:
> Phlip wrote:
>> Tim Trampedach wrote in message ne>>> I'm trying to do a quick dump of a javascript and style sheet located in
>>> their respective /public directories into an rhtml file.
>> <%=h File.read(RAILS_ROOT + '/public/javascript/my_source.js') %>
>> This is half introductory Ruby and half introductory Rails, so one might
>> consider reading a little of the excellent books on these subjects,
>> offline, for a while!
>
> Rails questions are better directed to Rails mailing list, where you'll get
> better, faster, information.

While Philip may have assumed that Tim was using Rails, there was nothing
in the original post to indicate that Rails is involved. It's just ERB to
produce HTML (in this case with embedded JS and CSS), which comes up in
other contexts.

> James Britt
--Greg


James Britt

9/18/2007 2:16:00 AM

0

Gregory Seidman wrote:

>
> While Philip may have assumed that Tim was using Rails, there was nothing
> in the original post to indicate that Rails is involved. It's just ERB to
> produce HTML (in this case with embedded JS and CSS), which comes up in
> other contexts.


Amazingly true.

My reply was to suggest a better place for Rails help if this was in
fact part of a Rails matter.


--
James Britt

"I have the uncomfortable feeling that others are making a religion
out of it, as if the conceptual problems of programming could be
solved by a single trick, by a simple form of coding discipline!"
- Edsger Dijkstra