# Can I get RubyOnRails to read and parse an html file off har

**URL:** <https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301>\
**Category:** Rails\
**Created:** [August 17, 2006, 1:02pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301 "2006-08-17T13:02:02Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 17, 2006, 1:02pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/1 "2006-08-17T13:02:02Z")

</div>

I do this in ASP to read a special html template that I use, then modify  
in  
code before spitting out the resulting webpage.

Any ideas on how to script this in RUBY? Do I need a special GEM  
package?

D. Bruce M.

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 17, 2006, 1:44pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/2 "2006-08-17T13:44:06Z")

</div>

Hi Bruce,

This is in essence what the “view” files are for.

Check out the tutorials and docs linked on this page:

[http://www.rubyonrails.com/docs](http://www.rubyonrails.com/docs)

for help understanding how the framework works. It really is deceptively  
simple.

Best of luck and have fun…

Nicholas

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 17, 2006, 5:47pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/3 "2006-08-17T17:47:41Z")

</div>

Thanks, Nicholas!

I have looked over the VIEWS documentation and I find that I still want  
to  
be able to read an html file and handle the output myself.

Can this be done? Code suggestions?

D. Bruce M., BA, BGS, Dipl, MCP  
www.Gracenote.ca  
Winnipeg, MB  
(204) 772-5483

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 17, 2006, 5:56pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/4 "2006-08-17T17:56:44Z")

</div>

You can store templates anywhere (in the view dir, elsewhere on the  
server, in a database, on another server) and process them anyway  
you’d like before returning them to the client.

You can do any processing you want using Ruby. I’m assuming the  
processing code would go in the Controller.

If you want to wrap common output in simple functions, you can use  
helpers, and there’s a templating language called Radius:

- [http://rubyforge.org/projects/radius](http://rubyforge.org/projects/radius)

–  
Austin G.  
Thinking & Making: IA, UX, and IxD  
[http://thinkingandmaking.com](http://thinkingandmaking.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 17, 2006, 6:08pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/5 "2006-08-17T18:08:45Z")

</div>

Hi Bruce,

D. Bruce M. wrote:

> … to read a special html template that I use,  
> then modify in code before spitting out the  
> resulting webpage.

One approach would be to use REXML to read / write the file, then use  
'render :file =\> … ’ to display the web page.

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 17, 2006, 6:11pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/6 "2006-08-17T18:11:45Z")

</div>

Thanks Austin!

What I want to do is use my favourite html editor and embed my own (not  
use  
the “\<%”) tags for some specialized content.

I do NOT want to use the “\<%” stuff as the formatting looks wrong in my  
html  
editor. If I create my own template methodology (did this easy in ASP)  
my  
productivity goes up significantly.

I tried using Files.open but got some error…do I need to install some  
GEM  
or something to use FILES commands?

D. Bruce M., BA, BGS, Dipl, MCP  
www.Gracenote.ca  
Winnipeg, MB  
(204) 772-5483

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 17, 2006, 9:39pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/7 "2006-08-17T21:39:15Z")

</div>

On 8/17/06, D. Bruce M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> productivity goes up significantly.  
> Are you sure you want to use Rails then? Seems like you lose a lot of  
> the  
> benefits of Rails by not using the Ruby commands inside your view files.  
> There are html editors that will show the ruby codes nicely in your  
> rhtml  
> files.

I tried using Files.open but got some error…do I need to install some  
GEM

> or something to use FILES commands?

No, just plain Ruby should work. Try the commands out using irb  
(interactive  
ruby at command line) to try to figure out what problem you might be  
facing.  
Then once you’ve nailed it down, integrate the commands into your code.

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 17, 2006, 10:24pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/8 "2006-08-17T22:24:20Z")

</div>

I agree, you need to go back to .asp if you don’t like rails views

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 18, 2006, 1:09am UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/9 "2006-08-18T01:09:02Z")

</div>

Bill wrote:

> Charlie B. wrote:
> 
> > I agree, you need to go back to .asp if you don’t like rails views
> 
> I disagree with that. I recall seeing a markup for Rails that was HTML  
> editor friendly. Was it Markaby or something else? It was specifically  
> created to allow designers to work with the Rails templates.
> 
> Anyone recall what I’m referring to?
> 
> Bill

I’ll answer my question. It was Masterview but the site appears to not  
be responding. I can see it in google’s cache.

Bill

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 18, 2006, 1:06am UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/10 "2006-08-18T01:06:45Z")

</div>

Charlie B. wrote:

> I agree, you need to go back to .asp if you don’t like rails views

I disagree with that. I recall seeing a markup for Rails that was HTML  
editor friendly. Was it Markaby or something else? It was specifically  
created to allow designers to work with the Rails templates.

Anyone recall what I’m referring to?

Bill

---

<div class="post-metadata">

**Author:** ![DSBruce\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@DSBruce\_M](https://www.ruby-forum.com/u/DSBruce_M)\
**Post date:** [August 19, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/can-i-get-rubyonrails-to-read-and-parse-an-html-file-off-har/65301/11 "2006-08-19T17:53:04Z")

</div>

MasterView site ( [http://masterview.org/](http://masterview.org/) ) was intermittently down as  
we were upgrading some sites to be compatible with rails 1.1.6. We are  
done with the upgrades other than a hardware issue I am having tech  
support look at. I wouldn’t expect much downtime from this.

Let me know if you are still having trouble getting to the site.

Also note that project is stored on [Rubyforge.org](http://Rubyforge.org) so one can always  
pull gem from there.  
[http://rubyforge.org/projects/masterview](http://rubyforge.org/projects/masterview)

Thanks,

Jeff
