Ruby to HTML as PHP
rack-server-pages
A middleware and application for serving dynamic pages in a very simple way. No controllers or models, just jsp, asp and php!
https://github.com/migrs/rack-server-pages
fooobar.com/questions/1296329 / ...
You can run it with "rackup" or any rack that supports an application server. For example, with a passenger, you just need to go to the folder where config.ru is located and run "launch passenger".
source to share
You are looking for erb files.
Open the file test.erb
and write this down:
<h1><%= "hello" %></h1>
then start it with:
ruby -rerb -e 'puts ERB.new(File.read("test.erb")).result'
To run erb in a web browser you need to wrap it somehow.
Here is the stone that completes the task:
Serve - A framework for prototyping prototypes for web applications
gem install serve
And then run it in the directory where your scripts are located:
serve
Standard address - localhost: 4000
source to share
You can copy as much logic in the template as you like, but you still need an application server. PHP has this as mod_php or via FastCGI etc. Ruby offers many options. Consider serving or creating a bare bones sinut app.
Think about what goals you are trying to achieve. This is generally bad practice, and a lot of people have moved from old PHP style to more modern frameworks that avoid this pitfall. Perhaps this is because only 2 people are using it and you cannot find tutorials.
source to share