GithubHelp home page GithubHelp logo

acme-trinkets's Introduction

Acme Trinkets

After completing this project you will understand how to

  • use EJS with a Node application
  • create and load EJS templates
  • provide server data to EJS templates
  • dynamically build out UI elements using dynamic data

Prerequisites

  • Section 33: Creating Servers with Express
  • Section 34: Creating Dynamic HTML with Templating

Introduction

We learned that we can create JavaScript servers using Express and that we can also create dynamic web pages using EJS. In this exercise we will test our knowledge and understanding of the material by creating a basic website using Express and EJS

Instruction

  • Please fork and clone this repository. Regularly commit and push your code as appropriate.
  • Before you begin work, open up the project and get familiar with the pre-existing code. Be sure to read carefully

Project Layout

  • index.js: Server file where we register EJS and also create routes for our application
  • data.js: File that contains our data to be used with the project that we will create elements with
  • views/
    • home.ejs: The home page of the website
    • trinket.ejs: The details page for a specific trinket

Install and run the project

After opening the proect in VS Code (or any editor) open up a terminal and, navigate to the project folder and install the project by running

npm i

From there you can then run the project by running the command

npm run start:dev

Home.ejs

We want to be able to dynamically build out cards for EVERY trinket we have in our viewData array.

To do this replace the single card with a for loop that loops over the viewData array and replace the hard coded data with dynamic data

  • set the image src to the trinket imageUrl
  • replace the hard coded Trinket Name with the dynamic trinket name
  • replace the hard coded price with the dynamic trinket price
  • set the href of the shop button to /product/id where id is the dynamic trinket id

Trinket.ejs

We want a way to show the details of a selected trinket

  • provide the image src the trinket imageUrl
  • fill in the trinket name
  • fill in the trinket price
  • add in the trinket description

Results

Home page Home page

Details Details page

acme-trinkets's People

Contributors

acemouty avatar

Watchers

 avatar

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.