Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Web Development with Jade
  • Table Of Contents Toc
  • Feedback & Rating feedback
Web Development with Jade

Web Development with Jade

By : Sean Lang
4.3 (4)
close
close
Web Development with Jade

Web Development with Jade

4.3 (4)
By: Sean Lang

Overview of this book

Table of Contents (16 chapters)
close
close

Built-in logical operators


Writing JS can start to look ugly and doesn't really match with the indentation-based syntax that Jade uses, so we have several built-in logical operators that do the same thing, but are easier to write.

Here are a few examples:

If / else / else if

Jade

HTML

- name = "Bob"
if name == "Bob"
  h1 Hello Bob
else if name == "Joe"
  h1 Hello Joe
else
  h1 My name is #{name}
<h1>Hello Bob</h1>

Unless

Jade also provides unless which is equivalent to if (!(expr)), as illustrated in the following code snippet:

Jade

HTML

- name = "Bob"
unless name == "Bob"
  h1 My name is #{name}
else
  h1 Hello Bob
<h1>Hello Bob</h1>

Cases

Jade

HTML

- name = "Bob"
case name
  when "Bob"
    p Hi Bob!
  when "Alice"
    p Howdy Alice!
  default
    p Hello #{name}!
<p>Hi Bob!</p>

Each loops

Each is used for iterating over arrays and objects and is written in the following syntax:

each VAL[, KEY] in OBJ

An example is given in the following code snippet:

Jade

HTML...

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Web Development with Jade
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon