-1

Is there any way to easily convert HTML/asp code into a format so that it can be used as a string?

So, like there is some HTML/asp code, and I want to use this as string in ruby code. Is there any way to convert the HTML code into ruby string format?

Or is there anyway I can make the string of the ruby code to reference some HTML/asp file?

Edit: No, what I want to do is, I have some HTML code in HTML file, and I want to use it exactly as a string in ruby code.

For example,

I have code like blahblah and asp stuffs

Then I want to use the exact code as similar to this:

var = The code above.

But HTML/ASP code will have special characters that will make it hard to embed as a string. So is there any way to use the whole chunk as a string without encountering problem?

1 Answers1

0

This retrieves a web page and stores it into a string:

require 'open-uri'
html = open('http://www.example.com').read
puts html[0, 60]

Which outputs:

<!doctype html>
<html>
<head>
    <title>Example Domain</title>
the Tin Man
  • 158,662
  • 42
  • 215
  • 303