From 00debee607d1360656f42e95dc0c9db645d6e55d Mon Sep 17 00:00:00 2001 From: Arjun Krishna Date: Thu, 8 Oct 2020 07:00:45 +0530 Subject: [PATCH] Foreach hbs product layout: --- public/stylesheets/style.css | 8 --- routes/index.js | 30 ++++++++++- views/index.hbs | 96 +++++++++++++++++++++++++++++++++++- 3 files changed, 123 insertions(+), 11 deletions(-) diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 9453385..e69de29 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -1,8 +0,0 @@ -body { - padding: 50px; - font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; -} - -a { - color: #00B7FF; -} diff --git a/routes/index.js b/routes/index.js index ecca96a..2b0f6d2 100644 --- a/routes/index.js +++ b/routes/index.js @@ -3,7 +3,35 @@ var router = express.Router(); /* GET home page. */ router.get('/', function(req, res, next) { - res.render('index', { title: 'Express' }); + + var products = [ + { + name: "OnePlus Nord 5G", + category: "Mobile", + description: "Lorem Ipsum is simply dummy text of the printing and typesetting industry.", + imageURL: "https://images-na.ssl-images-amazon.com/images/I/719CgfLcqNL._SL1500_.jpg" + }, + { + name: "OnePlus 8 Pro", + category: "Mobile", + description: "Lorem Ipsum is simply dummy text of the printing and typesetting industry.", + imageURL: "https://images-na.ssl-images-amazon.com/images/I/61n6Ovq6EdL._SL1500_.jpg" + }, + { + name: "OnePlus 7T", + category: "Mobile", + description: "Lorem Ipsum is simply dummy text of the printing and typesetting industry.", + imageURL: "https://images-na.ssl-images-amazon.com/images/I/71ncRs6HzyL._SL1500_.jpg" + }, + { + name: "OnePlus 8", + category: "Mobile", + description: "Lorem Ipsum is simply dummy text of the printing and typesetting industry.", + imageURL: "https://images-na.ssl-images-amazon.com/images/I/61qGR60Ak9L._SL1500_.jpg" + }, +] + + res.render('index', { products }); }); module.exports = router; diff --git a/views/index.hbs b/views/index.hbs index 1f308fd..1705f84 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -1,2 +1,94 @@ -

{{title}}

-

Welcome to {{title}}

+ + + + + + + + + + + + Hello, world! + + + + +
+ +
+ +
+
+
+ + {{#each products}} +
+
+ Card image cap +
+
{{this.name}}
+

{{this.description}}

+ Add to Cart +
+
+
+ {{/each}} + +
+
+
+ + + + + + + + + \ No newline at end of file -- knotmirror 0.0.1