I have a piece of html text that includes some ruby variables, and depends on a loop with unknown number of iterations. What I have now (and works):
test.rb (piece)
head = <<-HEAD
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="scripts.js" type="text/javascript"></script>
</head>
<body>
HEAD
body = '<div class="flex-container">'
items.each do |i|
body << %(
<div class="container">
<button id='action#{i.ref}'
style="background-color: 'inherit';"
onmouseover="this.id='action'; this.style.background='highlight';"
onclick="selectItem()"
onmouseout="this.id='action#{i.ref}'; this.style.background='inherit';"
value="#{i.root}">
<img src="#{i.image}" alt="#{i.name}_img">
<div>#{i.name}</div>
</button>
</div>
)
end
body += '</div></body></html>'
html = head + body
That is the way I generate my html text. I want to have a separate html file and somehow link what's in the body to the ruby code of last example, i.e.:
test.html
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="scripts.js" type="text/javascript"></script>
</head>
<body>
<div class="flex-container">
<!-- HERE HAVE SOME LINK TO THE BODY OF test.rb -->
</div>
</body>
</html>
Any hint? Thanks.