January 2 - Using Ruby Here Doc Syntax to Dynamically Generate HTML Code
In this coding exercise we'll examine how to leverage the Ruby Here Doc syntax to generate HTML with dynamic content.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
  • Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license

Summary

Build a program that dynamically generates the HTML boilerplate code and dynamically integrate a custom title.

Exercise Description

Given the following strings:

'My Site'

and the HTML boilerplate code:

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">

  <title>Title Placeholder</title>
</head>

<body>
</body>
</html>

Write a program that generates the full HTML boilerplate code with the title integrated.

Sample Output

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">

  <title>My Site</title>
</head>

<body>
</body>
</html>

Real World Usage

This is a common process you will utilize whenever working with multi-line strings. Specifically, this is something you're likely to come across when you need to generate HTML code if you're working with web applications.

Test Cases

Code File