Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Web Development with Jade

You're reading from   Web Development with Jade Knowing Jade makes life simpler and more productive for web developers, and this book will teach you the language concisely and thoroughly using lots of practical examples and best practices for a solid grounding.

Arrow left icon
Product type Paperback
Published in Mar 2014
Publisher
ISBN-13 9781783286355
Length 80 pages
Edition Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Sean Lang Sean Lang
Author Profile Icon Sean Lang
Sean Lang
Arrow right icon
View More author details
Toc

Includes


The last way to insert content from another file is with an include statement. This is the simplest way, but also the least dynamic because you cannot change/generate the name of the file you want to include. This is because includes are one of the first things that are evaluated when compiling a template; before any loops, logical operations, or variables.

Still, they are quite useful for moving pieces of templates that are reused many times into their own files, or for including static assets such as HTML, CSS, or JS directly in templates.

Static

If you just want to include a static asset, the operation is very basic.

style.css:

p {
  color: blue;
  text-decoration: underline;
}

content.html (in the same directory as style.css):

<h1>includes</h1>
<p>this is a file for demonstrating the use of includes in Jade</p>

example.jade (in the same directory as style.css):

Jade

HTML

doctype
html
  head
    style(type="text/css")
      include style.css
  body
    include...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime