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

Sending the variables to the compiler


Defining all of your variables inside your templates would be pretty limiting, so there are a few ways in which we can send data from external sources to templates.

Compiler arg

The easiest way to send data to the Jade compiler is by just providing it in a JSON object that gets passed to the compiler as an argument, as shown in the following steps:

  1. In file.jade, enter the following:

     p= my_content
  2. Run the following command in the terminal:

     jade file.jade --obj '{"my_content":"this text is coming through the terminal"}'
  3. We can see the result in file.html:

     <p>this text is coming through the terminal</p>

Programmatically

Sending variables to Jade programmatically is a bit harder, but offers more flexibility, such as being able to render within the browser. So, using the same initial file (file.jade) perform the following steps:

  1. Run the following command in the terminal:

     jade file.jade --no-debug --client
  2. And we can see the following result in file.js...

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