Sinatra Views Lab II
Objectives
Respond to HTTP Requests with Sinatra Routes.
Render ERB from a Sinatra Action.
Overview
This lesson practices creating ERB views and rendering them from a Sinatra Action in response to an HTTP request. Fork and clone this repository and run bundle install to get started!
Instructions
For each of the following examples, create a .erb file in the views directory and a route in app.rb which renders that template. Make sure each template contains the requested content.
Run shotgun to start a local server so that you can test your app in your browser. Once your application is running, assuming port 9393, the shotgun default, you should be able to hit the following local urls: http://localhost:9393/hello, http://localhost:9393/goodbye, and http://localhost:9393/date.
You can run learn to get the tests passing and see errors.
Create a template called
hello.erbinviewsthat contains anh1tag with the contentHello World. This should get rendered via a GET/helloroute by yourAppcontroller inapp.rb.Create another template called
goodbye.erbinviews. In this view, use ERB tags to create a variablename. This variable should store the nameJoe. Then, using ERB tags, say "Goodbye Joe" in anh1tag. This should get rendered via a GET/goodbyeroute by yourAppcontroller inapp.rb.Create a template called
date.erbinviewsthat gets rendered via GET/date. It should contain anh1with the contentToday
Using ERB tags, and the DateTime library, display today's date in a p tag. The date should be formatted to look something like this The date is Wednesday, November 18, 2015.
Clone this lab here: https://github.com/learn-co-curriculum/sinatra-views-lab
Last updated