Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3547 > unrolled thread
| Started by | Scott Elwood <elwood32@live.com> |
|---|---|
| First post | 2011-04-27 01:01 -0500 |
| Last post | 2011-04-28 01:14 -0500 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.ruby
File.open of HTML file removes code Scott Elwood <elwood32@live.com> - 2011-04-27 01:01 -0500
Re: File.open of HTML file removes code Nikita Baksalyar <n.baksalyar@yandex.ru> - 2011-04-27 01:52 -0500
Re: File.open of HTML file removes code Brian Candler <b.candler@pobox.com> - 2011-04-27 02:49 -0500
Re: File.open of HTML file removes code Scott Elwood <elwood32@live.com> - 2011-04-27 13:57 -0500
Re: File.open of HTML file removes code 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-27 19:39 -0500
Re: File.open of HTML file removes code Scott Elwood <elwood32@live.com> - 2011-04-28 01:14 -0500
| From | Scott Elwood <elwood32@live.com> |
|---|---|
| Date | 2011-04-27 01:01 -0500 |
| Subject | File.open of HTML file removes code |
| Message-ID | <f35f5a43da863832e708040011124ed4@ruby-forum.com> |
Hey there,
I am trying to edit an erb file in ruby, however when I do:
file.open("index.erb")
It displays the information, but removes the Doctype, html, body, and
head tags.
Is there any way to read the entire contents of the .erb file?
--
Posted via http://www.ruby-forum.com/.
[toc] | [next] | [standalone]
| From | Nikita Baksalyar <n.baksalyar@yandex.ru> |
|---|---|
| Date | 2011-04-27 01:52 -0500 |
| Message-ID | <c48b9773e1e005682aff99256a89fd44@ruby-forum.com> |
| In reply to | #3547 |
Hello,
Please try to run this commands in your OS command prompt:
For Windows:
type index.erb
For Linux/Mac OS X:
cat index.erb
And then:
$ irb
irb(main):001:0> File.open('index.erb').read
Then compare system output with Ruby's output - if they have no
differences - the problem is somewhere in your code. In that case please
post your code to www.pastebin.com and give a link there.
Good luck. :)
--
Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [next] | [standalone]
| From | Brian Candler <b.candler@pobox.com> |
|---|---|
| Date | 2011-04-27 02:49 -0500 |
| Message-ID | <c1c6d5c520b80bd4b1bf31214611f456@ruby-forum.com> |
| In reply to | #3547 |
Scott Elwood wrote in post #995260:
> Hey there,
>
> I am trying to edit an erb file in ruby, however when I do:
>
> file.open("index.erb")
>
> It displays the information, but removes the Doctype, html, body, and
> head tags.
>
> Is there any way to read the entire contents of the .erb file?
File.open("...") just opens the file and returns an open File object,
but it doesn't read it until you ask it to.
Try:
File.open("index.erb") do |file|
file.each_line do |line|
puts line
end
end
--
Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [next] | [standalone]
| From | Scott Elwood <elwood32@live.com> |
|---|---|
| Date | 2011-04-27 13:57 -0500 |
| Message-ID | <188b9aabd4a7d3d2732aced0c2a27b7d@ruby-forum.com> |
| In reply to | #3547 |
Thanks to both of you!
I checked both of the code you guys suggested and it worked fine.
However there is still a problem.
I am developing an application for a ruby class I am in, and I would
like to edit some of that .erb file in an HTML textarea. I am using
Ruby/Sinatra, and here is what happens:
If I print the data into a <div>, it will show everything including the
doctype, body, etc.
Yet when I do this:
<textarea cols="93" rows="32" name="contents">
<% File.open("views/layoutAdmin.erb") do |file| %>
<% file.each_line do |line| %>
<%= line %>
<% end %>
<% end %>
</textarea>
The textarea will take away all of the aforementioned tags. Like I said
before, if I replace the <textarea> tags with <div> tags, it works fine,
but I of course can't edit that content.
Is there some reason why textareas do not display this data?
--
Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [next] | [standalone]
| From | 7stud -- <bbxx789_05ss@yahoo.com> |
|---|---|
| Date | 2011-04-27 19:39 -0500 |
| Message-ID | <71190b82c92243ccf754ca937e60a73d@ruby-forum.com> |
| In reply to | #3570 |
Scott Elwood wrote in post #995373: > Thanks to both of you! > > I checked both of the code you guys suggested and it worked fine. > However there is still a problem. > > I am developing an application for a ruby class I am in, and I would > like to edit some of that .erb file in an HTML textarea. You need to post that .erb file. Or, even better, create the most minimal .erb file you can that will still exhibit your problem. > > If I print the data into a <div>, > Huh? What data? What <div>? > > Is there some reason why textareas do not display this data? > Huh? I thought we were talking about an .erb file? erb files don't display anything. -- Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [next] | [standalone]
| From | Scott Elwood <elwood32@live.com> |
|---|---|
| Date | 2011-04-28 01:14 -0500 |
| Message-ID | <d32dc68e9c208e93895e18b8f9402467@ruby-forum.com> |
| In reply to | #3547 |
Thanks again for the comment, it led me to test some stuff out and found it was TinyMCE javascript plugin that was removing the header and such. I tried testing if that was the case earlier but a refresh of the page didn't refresh the code, I had to actually reload the page for it to reset. Sorry for the confusion, this is a great forum :) -- Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.ruby
csiph-web