Giter Site home page Giter Site logo

sinatra-views-lab's Introduction

Sinatra Views Lab

Objectives

  1. Respond to HTTP Requests with Sinatra Routes.
  2. 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 test to get the tests passing and see errors.

  1. Create a template called hello.erb in views that contains an h1 tag with the content Hello World. This should get rendered via a GET /hello route by your App controller in app.rb.

  2. Create another template called goodbye.erb in views. In this view, use ERB tags to create a variable name. This variable should store the name Joe. Then, using ERB tags, say "Goodbye Joe" in an h1 tag. This should get rendered via a GET /goodbye route by your App controller in app.rb.

  3. Create a template called date.erb in views that gets rendered via GET /date. It should contain an h1 with the content Today

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 Friday, August 06, 2021.

Note: The date must match this format exactly, including the 06 for the date if it's in the first nine days of the month. Check out the spec file to see how to get this format if you're stuck!

sinatra-views-lab's People

Contributors

annjohn avatar aviflombaum avatar dannyd4315 avatar ihollander avatar ipc103 avatar jmburges avatar maxwellbenton avatar timothylevi avatar victhevenot avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sinatra-views-lab's Issues

Should practice doing ruby in the erb

Currently this is just straight HTML. They've already practiced that. Add in doing some basic ruby in the erb. They don't know how to pass variables in from the controller yet, so just things like the current time? Any other ways you can do some ruby stuff without passing in variables. Make sure it has at least one <%= and one <%

Need for strftime tutorial resource to focus lab learning on ERB

--> 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.

In this lab it would be helpful to list a tutorial resource on strftime. I felt like I spent more time figuring that part out than completing the rest of the lab. Thanks!

Passed this lab without having to use the 'name' variable

I passed this lab--and only afterwards remembered I was going to go back and add the name variable.
Not sure whether this is a problem, but here's my code in 'goodbye.erb':

<!DOCTYPE html>
<html>
  <head>
    <title>Bye</title>
  </head>
  <body>
    <h1>Goodbye Joe</h1>
  </body>
</html>

Error 500

I believe I have the correct code to pass all of these tests however, it keeps returning error 500 for the /date portion of this lab. Also the other tests will pass and nothing will be displayed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.