What would be the closest thing to having Ruby in HTML like for PHP with <?php ?>
tags?
Can it be done without the need of frameworks that impose website structure or without the need to run Ruby servers, ecc... ?
Is there a way?
Rack middleware and application for serving dynamic pages in very simple way. There are no controllers or models, just only views like a jsp, asp and php!
https://github.com/migrs/rack-server-pages
https://stackoverflow.com/a/32938202/988591
You can run it with "rackup" or any app server supporting rack. For example with passenger you just need to go to the folder where config.ru is and run "passenger start".
You're looking for erb files.
Open a test.erb
file and write this down:
<h1><%= "hello" %></h1>
then run it with:
ruby -rerb -e 'puts ERB.new(File.read("test.erb")).result'
To run erb within a webser you need to wrap it somehow.
Here is a gem that does the job:
Serve - A Rapid Prototyping Framework for Web Applications
gem install serve
And then run it on the directory where your scripts are:
serve
The standard address is localhost:4000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With