Austin Burke
Austin Burke

Reputation: 148

Best way to use ERB 'in browser' similar to opening an html in browser

I have a program at work that everyone can access via an index.html shortcut. They access the file through File Explorer. I want to embed some Ruby and render it via html, but without going through Rails/Sinatra since that would require actually a) hosting the site or b) running it on a server every time to access it.

I want my co-workers to be able to simply double-click the index.html shortcut and it pop up in their browser as it does now. BUT with embedded ruby so that I can add some different functionality beyond html/css.

Is this possible? If so, best route?

Upvotes: 0

Views: 306

Answers (1)

NM Pennypacker
NM Pennypacker

Reputation: 6942

In order to use the .erb templating engine you'll have to make sure that the server that serves the HTML page has Ruby installed, as well as some HTTP routing mechanism that responds to the request, processes the embedded Ruby, and renders the HTML result.

So to answer your question, if you want to use ERB, you will have to install Ruby on your web server at bare minimum.

You would save yourself a lot of time by using a minimal framework like Sinatra, but it is possible to build something from scratch in pure Ruby, since the ERB class is included in Ruby core.

Not sure how dynamic you need the page to be, or how much user input alters the page, but you may be able to do what you need with a combination of JavaScript/cookies/localstorage.

Upvotes: 2

Related Questions