SlideShare a Scribd company logo
1 of 17
Download to read offline
JADE (PUG)
Date / Time : 09.08.2016 Presented by: Sivaram.N
Agenda
❏ Introduction
❏ Basic Topics
❏ Advanced Topics
Introduction
● Jade is Templating Language
● It is Clean and minimal html
● It is Originally Packaged as node module
● Indentation based language (we can use either spaces or tabs not both.)
● Available for Python, Ruby etc…
● Recently Jade renamed as pug
Introduction (2)
● Installation
$ npm install -g jade / pug
● Checking Jade version
$ npm ls -g jade / pug
● Command line interface
$ jade --help / pug --help
Basic Topics
● Tags and Text
● Nesting
● Variables and comments
● Classes, Ids and Attributes
● Conditions (if, else, unless)
● Loops and Iteration
Tags and Text
# Tags
● First word is a Tag
○ p, div, h1 etc...
● Jade knows self-closing tags
○ img, input etc...
# Text
● Everything after first word is text
○ p Hello, World
○ echo “p Hello, world” | jade
● For multi-line text, use pipes '|'
○ p
| Hello
| This is Jade
Nesting
● Just add a new line and a tab per indent level
div
p
h1 Nesting Example
p
strong Hello, World
Variables and Comments
# variables
● Variables are used to store value
○ title = “welcome to Jade”
h1 = title
# Comments
● Single line comments just like javascript comments
○ // p (visible in DOM)
○ //- p (invisible in DOM)
● Multi-line / Block Comments
○ body
//
Classes, Ids and Attributes
# Classes and Ids
● Use Class Selectors
● The html class attribute is “.classname”
● Can have multiple classes
○ p.col-md-2
○ div.row.col-md-6 (.row.col-md-6: for div no need for use ‘div’)
● The html id attribute is “#idname”
○ div#wrap
● Can Combain Class and Id
○ #container
.row.col-md-1
# Attributes
● Html like in a javascript syntax
○ a(href=”google.com”) Google
○ img.row(alt=”img”, title=”img”, src=”img.png”)
Conditions
● Simple if/else statement same as like javascript
● No braces
○ - var color = ‘red’
if color == ‘red’
p.red Hello, World
else
p.yellow Hello, World
● Unless is negative evolution
○ - var color = ‘red’
unless color == ‘red’ // if color !=’red’
p.yellow Hello, World
Loops
● Iteration over arrays or objects
○ ul
each val in [1,2,3,4,5]
li = val
● Can also ‘for’ keyword’
○ ul
for val in [1,2,3,4,5]
li = val
● Can get index while iteration
○ ul
each val, index in in [one, two, three]
li = index+”:”+val
● Iterate over keys in object
○ ul
each val,index in {1:’one’, 2:’two’}
Advanced Topics
● Template Includes
● Template Inheritance
● Mixins
● Miscellaneous
Template Includes
● One of the most powerful feature
● Allow code reuse
● Write Once, use multiple times
● You Can include different jade file into different once
● Can have multiples includes in a file
❖ include <template>.jade
Template Inheritance
● Jade supports template inheritance via the block and extends keywords
● A block is simply a "block" of Jade that may be replaced within a child
template
layout.jade
doctype html
head
title My Site
block scripts
script(src='/jquery.js')
body
block content
block foot
#footer
p some footer content
sub-layout.jade
extends ./layout.jade
block scripts
script(src='/jquery.js')
script(src='/pets.js')
block content
h1= title
Mixins
● Mixins allow you to create reusable blocks of jade
● Declaration
mixin list
ul
li foo
li bar
li baz
//- Usage
+list
+list
● Mixins can also take a block of jade to act as the content
References
● http://jade-lang.com/
● https://naltatis.github.io/jade-syntax-docs/
● https://github.com/sivaram143/my_lms/blob/master/jade-examples.zip
● http://html2jade.org/
● https://www.npmjs.com/package/pug
● http://code.runnable.com/UTlPPF-f2W1TAAEe/render-jade-with-express-for-node-js
● https://pherricoxide.wordpress.com/2013/07/24/jade-mixins-blocks-attributes-and-more/
Thanks for listening ...
Sivaram.N
Software Engineer

More Related Content

Viewers also liked

Python_Session
Python_SessionPython_Session
Python_Sessionsiva ram
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17siva ram
 
Pug - a compiler pipeline
Pug - a compiler pipelinePug - a compiler pipeline
Pug - a compiler pipelineForbes Lindesay
 
Jade V
Jade VJade V
Jade Vtmtm99
 
All about agents jade
All about agents jadeAll about agents jade
All about agents jadeAryan Rathore
 
Matlab simulink introduction
Matlab simulink introductionMatlab simulink introduction
Matlab simulink introductionAmeen San
 

Viewers also liked (8)

Python_Session
Python_SessionPython_Session
Python_Session
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
 
Keynesianismus
KeynesianismusKeynesianismus
Keynesianismus
 
Pug - a compiler pipeline
Pug - a compiler pipelinePug - a compiler pipeline
Pug - a compiler pipeline
 
Jade V
Jade VJade V
Jade V
 
All about agents jade
All about agents jadeAll about agents jade
All about agents jade
 
Simulink
SimulinkSimulink
Simulink
 
Matlab simulink introduction
Matlab simulink introductionMatlab simulink introduction
Matlab simulink introduction
 

Similar to Jade

Learning groovy -EU workshop
Learning groovy  -EU workshopLearning groovy  -EU workshop
Learning groovy -EU workshopadam1davis
 
Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Mark Niebergall
 
Qore for the Perl Programmer
Qore for the Perl ProgrammerQore for the Perl Programmer
Qore for the Perl ProgrammerBrett Estrade
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAhmed Salama
 
Smalltalk, the dynamic language
Smalltalk, the dynamic languageSmalltalk, the dynamic language
Smalltalk, the dynamic languagemohamedsamyali
 
JavaScript Getting Started
JavaScript Getting StartedJavaScript Getting Started
JavaScript Getting StartedHazem Hagrass
 
Structured web programming
Structured web programmingStructured web programming
Structured web programmingahfast
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersKirk Kimmel
 
2017: Kotlin - now more than ever
2017: Kotlin - now more than ever2017: Kotlin - now more than ever
2017: Kotlin - now more than everKai Koenig
 
Learning groovy 1: half day workshop
Learning groovy 1: half day workshopLearning groovy 1: half day workshop
Learning groovy 1: half day workshopAdam Davis
 
Introduction to JavaScript for Modern Software Development
Introduction to JavaScript for Modern Software DevelopmentIntroduction to JavaScript for Modern Software Development
Introduction to JavaScript for Modern Software DevelopmentKenneth Geisshirt
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScriptJorg Janke
 
go language- haseeb.pptx
go language- haseeb.pptxgo language- haseeb.pptx
go language- haseeb.pptxArsalanMaqsood1
 

Similar to Jade (20)

Learning groovy -EU workshop
Learning groovy  -EU workshopLearning groovy  -EU workshop
Learning groovy -EU workshop
 
Go_ Get iT! .pdf
Go_ Get iT! .pdfGo_ Get iT! .pdf
Go_ Get iT! .pdf
 
Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018Advanced PHP Simplified - Sunshine PHP 2018
Advanced PHP Simplified - Sunshine PHP 2018
 
Qore for the Perl Programmer
Qore for the Perl ProgrammerQore for the Perl Programmer
Qore for the Perl Programmer
 
Advanced PHP Simplified
Advanced PHP SimplifiedAdvanced PHP Simplified
Advanced PHP Simplified
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Dart workshop
Dart workshopDart workshop
Dart workshop
 
Ruby training day1
Ruby training day1Ruby training day1
Ruby training day1
 
Smalltalk, the dynamic language
Smalltalk, the dynamic languageSmalltalk, the dynamic language
Smalltalk, the dynamic language
 
JavaScript Getting Started
JavaScript Getting StartedJavaScript Getting Started
JavaScript Getting Started
 
Structured web programming
Structured web programmingStructured web programming
Structured web programming
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one liners
 
FluentDom
FluentDomFluentDom
FluentDom
 
2017: Kotlin - now more than ever
2017: Kotlin - now more than ever2017: Kotlin - now more than ever
2017: Kotlin - now more than ever
 
Learning groovy 1: half day workshop
Learning groovy 1: half day workshopLearning groovy 1: half day workshop
Learning groovy 1: half day workshop
 
Introduction to JavaScript for Modern Software Development
Introduction to JavaScript for Modern Software DevelopmentIntroduction to JavaScript for Modern Software Development
Introduction to JavaScript for Modern Software Development
 
Object Oriented Javascript
Object Oriented JavascriptObject Oriented Javascript
Object Oriented Javascript
 
Groovy.pptx
Groovy.pptxGroovy.pptx
Groovy.pptx
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
go language- haseeb.pptx
go language- haseeb.pptxgo language- haseeb.pptx
go language- haseeb.pptx
 

Jade

  • 1. JADE (PUG) Date / Time : 09.08.2016 Presented by: Sivaram.N
  • 2. Agenda ❏ Introduction ❏ Basic Topics ❏ Advanced Topics
  • 3. Introduction ● Jade is Templating Language ● It is Clean and minimal html ● It is Originally Packaged as node module ● Indentation based language (we can use either spaces or tabs not both.) ● Available for Python, Ruby etc… ● Recently Jade renamed as pug
  • 4. Introduction (2) ● Installation $ npm install -g jade / pug ● Checking Jade version $ npm ls -g jade / pug ● Command line interface $ jade --help / pug --help
  • 5. Basic Topics ● Tags and Text ● Nesting ● Variables and comments ● Classes, Ids and Attributes ● Conditions (if, else, unless) ● Loops and Iteration
  • 6. Tags and Text # Tags ● First word is a Tag ○ p, div, h1 etc... ● Jade knows self-closing tags ○ img, input etc... # Text ● Everything after first word is text ○ p Hello, World ○ echo “p Hello, world” | jade ● For multi-line text, use pipes '|' ○ p | Hello | This is Jade
  • 7. Nesting ● Just add a new line and a tab per indent level div p h1 Nesting Example p strong Hello, World
  • 8. Variables and Comments # variables ● Variables are used to store value ○ title = “welcome to Jade” h1 = title # Comments ● Single line comments just like javascript comments ○ // p (visible in DOM) ○ //- p (invisible in DOM) ● Multi-line / Block Comments ○ body //
  • 9. Classes, Ids and Attributes # Classes and Ids ● Use Class Selectors ● The html class attribute is “.classname” ● Can have multiple classes ○ p.col-md-2 ○ div.row.col-md-6 (.row.col-md-6: for div no need for use ‘div’) ● The html id attribute is “#idname” ○ div#wrap ● Can Combain Class and Id ○ #container .row.col-md-1 # Attributes ● Html like in a javascript syntax ○ a(href=”google.com”) Google ○ img.row(alt=”img”, title=”img”, src=”img.png”)
  • 10. Conditions ● Simple if/else statement same as like javascript ● No braces ○ - var color = ‘red’ if color == ‘red’ p.red Hello, World else p.yellow Hello, World ● Unless is negative evolution ○ - var color = ‘red’ unless color == ‘red’ // if color !=’red’ p.yellow Hello, World
  • 11. Loops ● Iteration over arrays or objects ○ ul each val in [1,2,3,4,5] li = val ● Can also ‘for’ keyword’ ○ ul for val in [1,2,3,4,5] li = val ● Can get index while iteration ○ ul each val, index in in [one, two, three] li = index+”:”+val ● Iterate over keys in object ○ ul each val,index in {1:’one’, 2:’two’}
  • 12. Advanced Topics ● Template Includes ● Template Inheritance ● Mixins ● Miscellaneous
  • 13. Template Includes ● One of the most powerful feature ● Allow code reuse ● Write Once, use multiple times ● You Can include different jade file into different once ● Can have multiples includes in a file ❖ include <template>.jade
  • 14. Template Inheritance ● Jade supports template inheritance via the block and extends keywords ● A block is simply a "block" of Jade that may be replaced within a child template layout.jade doctype html head title My Site block scripts script(src='/jquery.js') body block content block foot #footer p some footer content sub-layout.jade extends ./layout.jade block scripts script(src='/jquery.js') script(src='/pets.js') block content h1= title
  • 15. Mixins ● Mixins allow you to create reusable blocks of jade ● Declaration mixin list ul li foo li bar li baz //- Usage +list +list ● Mixins can also take a block of jade to act as the content
  • 16. References ● http://jade-lang.com/ ● https://naltatis.github.io/jade-syntax-docs/ ● https://github.com/sivaram143/my_lms/blob/master/jade-examples.zip ● http://html2jade.org/ ● https://www.npmjs.com/package/pug ● http://code.runnable.com/UTlPPF-f2W1TAAEe/render-jade-with-express-for-node-js ● https://pherricoxide.wordpress.com/2013/07/24/jade-mixins-blocks-attributes-and-more/
  • 17. Thanks for listening ... Sivaram.N Software Engineer