A quick demo of Pug (formally Jade) templating using a Node.js back end for Comp 20 at Tufts. This is a mock superhero card game, where users can view cards for superheroes.
The slides from the guest lecture can be found here.
Clone this repo Create a mongo database called "heroes" by running this command in your terminal
mongo heroes
Inside the mongo shell run these commands
db.heroes.insert({name: "Batman",health: 5,attack: 5, image:"batman.jpg", text:["Battlecry: Talks in a raspy voice","Deathrattle: Returns as Ben Affleck"]})
db.heroes.insert({name: "Superman",health: 100,attack: 100, image:"superman.jpg", text:["Charge","Battlecry: Wins you the game because he's mad overpowered"]})
Now run this example from inside the project directory.
nodejs index.js
Now visit localhost:5000/?hero=Batman in your browser.
- Insert some more heroes into the database - see if you can get them to load into the app.
- Change the header for all pages.
- Change the card template so the cards look different.
- Add a post route so that users can add their own heroes.
- Try to crash the app with bad input!