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

Extends


The extends keyword allows us to specify that a particular template extends another template. This means the template in which the keyword is used gets to modify the blocks of the other template.

The syntax is simple; using extends layout means that the template in which it is used gets to extend layout.jade (the .jade part of the filename is implied). Also, full paths can be used; like if layout.jade was one directory above the location of the current template, we could use ../layout to access it.

Replace

To replace the content of a block, we use the same syntax as defining a block, but it must be put in a template that extends the file in which the block was defined. For example, if we have a page in which we need both jQuery and underscore.js, we could redefine the scripts block as follows:

page1.jade (in the same directory as layout.jade):

Jade

HTML

extends layout

block scripts
  script(src='jquery.js')
  script(src='underscore.js')

block content
<!DOCTYPE html>
<html...
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 €18.99/month. Cancel anytime