How to use ruby ​​output in html?

I have a ruby ​​program to get json from api and separate values ​​from it and display them. I need to make an output in the form of html. How can I take values ​​from ruby ​​and pass it to html so that I can use that value.

+4
source share
3 answers

You can use tilt gem

For example, the template foo.html.haml :

 !!! 5 %html %head %title Rotten Potatoes! %body %h1.title Rotten Potatoes! Hey = yield! 

Then pass the name of the temple:

 template = Tilt::ERBTemplate.new('foo.html.haml') output = template.render { 'Joe' } # => html code with phrase 'Hey Joe!' 
+1
source

Perhaps just add another line of code to redirect to another page with options. Therefore, you can get the parameters and display them in html.

0
source

All Articles