1

I was trying to search if I can install eruby on my windows7 machine but couldnt find anything. I could find how to install it on apache. But I want to install it on my win7 machine.

I am hoping that I can use it by embedding it in HTML, like we embed vbscript in HTML and just open the html page. Am I on the right path?

Phrogz
  • 296,393
  • 112
  • 651
  • 745
user1207289
  • 3,060
  • 6
  • 30
  • 66
  • Do you need eRuby specifically, or would [Erubis](http://www.kuwata-lab.com/erubis/) do instead? What about [ERB](http://ruby-doc.org/stdlib-1.9.3/libdoc/erb/rdoc/ERB.html), which comes as part of Ruby itself? – Phrogz May 14 '12 at 19:10
  • @Phrogz I dont know whats the difference between eruby and Erubis. I was just trying to write something to autorefersh a page in vbscript. I happen to have some exp in ruby and I like how ruby does things , so I thought of exploring the solution in ruby and thats where I came across eruby and stuff. But I think I'll just look for a vbscript solution. – user1207289 May 18 '12 at 17:46
  • eRuby is a standalone C-based module that can be run externally, e.g. from Apache. Erubis is a pure-Ruby library that can be loaded in a Ruby program on any platform (where Ruby runs) and perform the conversion there. – Phrogz May 18 '12 at 17:47

1 Answers1

2

It sounds like you don't fully understand how eRuby works, so let me clarify:

When you use your web browser to open an HTML file on your computer, the web browser is reading the bytes of the file from disk, interpreting it as an HTML document, and displaying it accordingly. The web browser understands HTML (and JavaScript, and CSS).

Templating languages like ERB/eRuby/Erubis use the Ruby programming language to run arbitrary code embedded in a web page and replace the results of that code with the text it produces. This final text is sent to the web browser; the browser never sees the Ruby code, but instead sees only HTML (and JavaScript, and CSS).

For this to happen, the web browser cannot open a file from disk:
file:///C:/Users/Phrogz/Desktop/foo.erb
...but must instead request the file from a web server (like Apache):
http://localhost/test/foo
which runs the eRuby processor before sending the modified content to the browser.

You can make a very simple web server with Ruby that processes content by using a simple web framework, such as Sinatra. However, this still requires you to start the web server process on your computer before making the request.

So, in short:

No, you cannot "install eRuby on Windows 7" such that opening a file from disk with the web browser runs Ruby code.

If you need a no-server solution, you might instead look at a client-side templating language such as dust.js which runs in JavaScript on the web browser and thus can be served from the simple file: protocol.

If you can have a server, I recommend Sinatra and (instead of ERB) using Haml as your templating language.

Phrogz
  • 296,393
  • 112
  • 651
  • 745