← helloexpress

partial-jade - in the user.jade we have the text that we would use as the list item - home.jade includes the user.jade - make sure that the object or vars that the partial expects are in memory

56ad20777e71b9f666fa66d74d379c4b17c3e57c · ovidiucs · Apr 17, 2014 12:20

+32 −15 · 2 files changed

  • views/home.jade +31 −15
  • views/user.jade +1 −0
diff --git a/views/home.jade b/views/home.jade
index b8572f0..54fefc5 100644
--- a/views/home.jade
+++ b/views/home.jade
@@ -4,7 +4,7 @@ extends layout
 block head
    title My Awsome Page
    style(type='text/css').
-      p { background:blue }
+      p { background:gray }
 
 
 block content
@@ -17,19 +17,35 @@ block content
         else
             h1 Description
             p.description User has no description
-
+    
     h1 My Awsome Page
     p
-       | Some really awsome copy
-    ul
-       li One
-       li Two
-       li Three
-    ul
-       li #{name}
-       li
-       li
-    ul
-       li
-       li
-       li
+        | Some really awsome copy
+    // Reuse Block of code using mixin
+    mixin list
+        ul
+           li One
+           li Two
+           li Three
+        ul
+           li #{name}
+    +list()
+    +list()
+    
+    mixin article(title)
+        .article
+            .article-wrapper
+                h1=title
+                if block
+                    block
+                else
+                    p No content provided
+    +article("Hello World")
+    +article("Hello World")
+        p This is my
+        p Amazing article
+
+    - var userlist = [ {name:"user1", email :"email@email.com"},{name:"user2", email :"enail2@email.com"} ];
+      ul
+          each userObject, i in userlist
+            include user 
diff --git a/views/user.jade b/views/user.jade
new file mode 100644
index 0000000..6489500
--- /dev/null
+++ b/views/user.jade
@@ -0,0 +1 @@
+li #{userObject.name} <#{userObject.email}> from the user.jade