Ruby to HTML as PHP

What would be the closest thing to making Ruby in HTML look like PHP with tags <?php ?>

?

Can this be done without using frameworks that enforce the site structure or without having to run Ruby servers, ecc ...?

Is there a way?

+3


source to share


3 answers


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".

+2


source


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

+1


source


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.

+1


source







All Articles