SlideShare a Scribd company logo
1 of 17
Using Jade, Stylus and NodeJS Together with 
Grunt 
Web Development: 
Making it the right 
way 
Yagiz Nizipli 
Software Engineer
My Past 
Computer engineer, musician, geek. But what have I really 
been doing for the past 2 years?
Projects contributed
Open-Source Initiative 
❖ Always a fan of open-source projects. 
❖ github.com/anonrig
Grunt - The Javascript Task 
Runner 
❖ Automation 
❖ Minification, unit testing, linting 
❖ Test-driven programming 
❖ Step by step compilation
Using NodeJs with Grunt 
❖ Node.Js is an event-driven, non-blocking i/o solution for 
asynchronous application development. 
❖ On top of the language Javascript. 
❖ An example use for Node.Js with Grunt is using file 
stream library in Node.Js. 
❖ Require it using: var fs = require('fs');
An example page for our mobile 
application 
<head> 
<title>My Application</title> 
… some meta tags here … 
<stylesheets/> 
</head> 
<body> 
<script type=“text/javascript”> 
myEnvironmentVariable = {}; 
<environment/> 
</script> 
</body>
❖ Local, test and 
production 
local: { 
input:"www/index.html", 
output:"www/index.html", 
tokens: [{ 
token: "<environment/>", 
string: fs.readFileSync(‘src/config/local.js').toString() 
}] 
}, 
test: { 
input: "www/index.html", 
output: "www/index.html", 
tokens: [{ 
token: "<directives/>", 
string: fs.readFileSync('src/config/test.js').toString() 
}] 
}, 
production: { 
input: "www/index.html", 
output: "www/index.html", 
tokens: [{ 
token: "<directives/>", 
string: fs.readFileSync(‘src/config/production.js').toString() 
}] 
}
Why we need a template 
engine? 
❖ Don’t waste time on markup languages. 
❖ Reuse the code whenever it’s possible. 
❖ Indentation is the key point. 
❖ Use if compilation is inevitable.
Introducing Jade 
❖ Jade, accessed from jade-lang.com, is a node template 
engine for HTML5 and JavaScript. 
❖ Enables us to use HTML without the markup 
functionality. 
❖ Compiles Jade code to HTML5 and JS. 
❖ How?
An example Jade code 
Jade
Introducing Stylus 
❖ Stylus, defined by the developers, is a expressive, 
robust, feature-rich CSS preprocessor. 
❖ CSS without the unnecessary syntax. 
❖ Enables to reuse the same CSS code for multiple rules. 
❖ How?
Example Stylus code 
An everyday stylus use Using Stylus with setting variables 
body 
font 12px Helvetica, Arial, sans-serif 
a.button 
-webkit-border-radius 5px 
-moz-border-radius 5px 
border-radius 5px 
fonts = helvetica, arial, sans-serif 
body 
padding 50px 
font 14px/1.4 fonts
What now? 
❖ How to compile these engines without knowing? 
❖ That’s why we need Grunt. 
❖ Grunt offers grunt-contrib-stylus and grunt-contrib-jade 
tasks to compile both of these engines.
An example of Grunt file 
grunt.initConfig({ 
clean: { 
before: ['www/img', 'www/css', 'www/compiled'] 
}, 
jade: { 
compile: { 
options: { 
pretty: true, 
data: { 
debug: true 
} 
}, 
files: [{ 
cwd: "src", 
src: "**/*.jade", 
dest: "www", 
expand: true, 
ext: ".html" 
}] 
} 
}, 
stylus: { 
build: { 
options: { 
linenos: false, 
compress: true 
}, 
files: [{ 
expand: true, 
cwd: 'src/css', 
src: [ '**/*.styl' ], 
dest: 'www/css', 
ext: '.css' 
}] 
} 
}, 
});
Sample project demo 
github.com/anonrig/gjs-example
Thank you for listening. 
Any questions? 
Yagiz Nizipli 
yagiznizipli@me.com 
github.com/anonrig 
yagiz.nizipli.com

More Related Content

What's hot

Css,javascript,php,mysql
Css,javascript,php,mysqlCss,javascript,php,mysql
Css,javascript,php,mysqlvurimi prasad
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsEdy Segura
 
Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Stefan Adolf
 
JavaScript Engine and WebAssembly
JavaScript Engine and WebAssemblyJavaScript Engine and WebAssembly
JavaScript Engine and WebAssemblyChanghwan Yi
 
Clojure Lightning Talk
Clojure Lightning TalkClojure Lightning Talk
Clojure Lightning TalkGiltTech
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An IntroductionNirvanic Labs
 
Speed up your zombies! - Bootstrap dev environment in 5 minutes!
Speed up your zombies! - Bootstrap dev environment in 5 minutes!Speed up your zombies! - Bootstrap dev environment in 5 minutes!
Speed up your zombies! - Bootstrap dev environment in 5 minutes!Krzysztof (Chris) Ozog
 
Server-side JavaScript for the rest of us
Server-side JavaScript for the rest of usServer-side JavaScript for the rest of us
Server-side JavaScript for the rest of usKyle Simpson
 
Building Native Android Apps with JavaScript
Building Native Android Apps with JavaScriptBuilding Native Android Apps with JavaScript
Building Native Android Apps with JavaScriptAbhishek Kant
 
Angular js
Angular jsAngular js
Angular jsTed Hsu
 
NPM, Bower and Gulp Kickstart in Visual Studio
 NPM, Bower and Gulp Kickstart in Visual Studio NPM, Bower and Gulp Kickstart in Visual Studio
NPM, Bower and Gulp Kickstart in Visual StudioAxilis
 

What's hot (17)

Css,javascript,php,mysql
Css,javascript,php,mysqlCss,javascript,php,mysql
Css,javascript,php,mysql
 
Modern front-end Workflow
Modern front-end WorkflowModern front-end Workflow
Modern front-end Workflow
 
Node.js with Express
Node.js with ExpressNode.js with Express
Node.js with Express
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019
 
Gatsby vs. Next.js
Gatsby vs. Next.jsGatsby vs. Next.js
Gatsby vs. Next.js
 
New paradigms
New paradigmsNew paradigms
New paradigms
 
JavaScript Engine and WebAssembly
JavaScript Engine and WebAssemblyJavaScript Engine and WebAssembly
JavaScript Engine and WebAssembly
 
Clojure Lightning Talk
Clojure Lightning TalkClojure Lightning Talk
Clojure Lightning Talk
 
JS & NodeJS - An Introduction
JS & NodeJS - An IntroductionJS & NodeJS - An Introduction
JS & NodeJS - An Introduction
 
Speed up your zombies! - Bootstrap dev environment in 5 minutes!
Speed up your zombies! - Bootstrap dev environment in 5 minutes!Speed up your zombies! - Bootstrap dev environment in 5 minutes!
Speed up your zombies! - Bootstrap dev environment in 5 minutes!
 
React Native.pptx (2)
React Native.pptx (2)React Native.pptx (2)
React Native.pptx (2)
 
Server-side JavaScript for the rest of us
Server-side JavaScript for the rest of usServer-side JavaScript for the rest of us
Server-side JavaScript for the rest of us
 
Building Native Android Apps with JavaScript
Building Native Android Apps with JavaScriptBuilding Native Android Apps with JavaScript
Building Native Android Apps with JavaScript
 
Paperclip
PaperclipPaperclip
Paperclip
 
Angular js
Angular jsAngular js
Angular js
 
NPM, Bower and Gulp Kickstart in Visual Studio
 NPM, Bower and Gulp Kickstart in Visual Studio NPM, Bower and Gulp Kickstart in Visual Studio
NPM, Bower and Gulp Kickstart in Visual Studio
 

Similar to Web Development: Making it the right way

WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CIRan Bar-Zik
 
Confoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to startConfoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to startQuentin Adam
 
Node, express & sails
Node, express & sailsNode, express & sails
Node, express & sailsBrian Shannon
 
Java script anywhere. What Nombas was doing pre-acquisition.
Java script anywhere. What Nombas was doing pre-acquisition.Java script anywhere. What Nombas was doing pre-acquisition.
Java script anywhere. What Nombas was doing pre-acquisition.Brent Noorda
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScriptOleg Podsechin
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.jsDmytro Ovcharenko
 
Difference between Node.js vs Java script
Difference between Node.js vs Java scriptDifference between Node.js vs Java script
Difference between Node.js vs Java scriptGhulamHussain799241
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingAndrea Giannantonio
 
JSX - developing a statically-typed programming language for the Web
JSX - developing a statically-typed programming language for the WebJSX - developing a statically-typed programming language for the Web
JSX - developing a statically-typed programming language for the WebKazuho Oku
 
Java Script recruiting
Java Script recruitingJava Script recruiting
Java Script recruitingIhor Odynets
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptSpike Brehm
 
JavaScript : A trending scripting language
JavaScript : A trending scripting languageJavaScript : A trending scripting language
JavaScript : A trending scripting languageAbhayDhupar
 
Webconf nodejs-production-architecture
Webconf nodejs-production-architectureWebconf nodejs-production-architecture
Webconf nodejs-production-architectureBen Lin
 

Similar to Web Development: Making it the right way (20)

Lightning fast sass
Lightning fast sassLightning fast sass
Lightning fast sass
 
WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CI
 
Confoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to startConfoo - Javascript Server Side : How to start
Confoo - Javascript Server Side : How to start
 
Node, express & sails
Node, express & sailsNode, express & sails
Node, express & sails
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
 
Nodejs
NodejsNodejs
Nodejs
 
NodeJS and what is actually does
NodeJS and what is actually doesNodeJS and what is actually does
NodeJS and what is actually does
 
Java script anywhere. What Nombas was doing pre-acquisition.
Java script anywhere. What Nombas was doing pre-acquisition.Java script anywhere. What Nombas was doing pre-acquisition.
Java script anywhere. What Nombas was doing pre-acquisition.
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
 
Nodejs
NodejsNodejs
Nodejs
 
NodeWay in my project & sails.js
NodeWay in my project & sails.jsNodeWay in my project & sails.js
NodeWay in my project & sails.js
 
Difference between Node.js vs Java script
Difference between Node.js vs Java scriptDifference between Node.js vs Java script
Difference between Node.js vs Java script
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
 
JSX - developing a statically-typed programming language for the Web
JSX - developing a statically-typed programming language for the WebJSX - developing a statically-typed programming language for the Web
JSX - developing a statically-typed programming language for the Web
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
 
Java Script recruiting
Java Script recruitingJava Script recruiting
Java Script recruiting
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScript
 
JavaScript : A trending scripting language
JavaScript : A trending scripting languageJavaScript : A trending scripting language
JavaScript : A trending scripting language
 
Webconf nodejs-production-architecture
Webconf nodejs-production-architectureWebconf nodejs-production-architecture
Webconf nodejs-production-architecture
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 

Web Development: Making it the right way

  • 1. Using Jade, Stylus and NodeJS Together with Grunt Web Development: Making it the right way Yagiz Nizipli Software Engineer
  • 2. My Past Computer engineer, musician, geek. But what have I really been doing for the past 2 years?
  • 4. Open-Source Initiative ❖ Always a fan of open-source projects. ❖ github.com/anonrig
  • 5. Grunt - The Javascript Task Runner ❖ Automation ❖ Minification, unit testing, linting ❖ Test-driven programming ❖ Step by step compilation
  • 6. Using NodeJs with Grunt ❖ Node.Js is an event-driven, non-blocking i/o solution for asynchronous application development. ❖ On top of the language Javascript. ❖ An example use for Node.Js with Grunt is using file stream library in Node.Js. ❖ Require it using: var fs = require('fs');
  • 7. An example page for our mobile application <head> <title>My Application</title> … some meta tags here … <stylesheets/> </head> <body> <script type=“text/javascript”> myEnvironmentVariable = {}; <environment/> </script> </body>
  • 8. ❖ Local, test and production local: { input:"www/index.html", output:"www/index.html", tokens: [{ token: "<environment/>", string: fs.readFileSync(‘src/config/local.js').toString() }] }, test: { input: "www/index.html", output: "www/index.html", tokens: [{ token: "<directives/>", string: fs.readFileSync('src/config/test.js').toString() }] }, production: { input: "www/index.html", output: "www/index.html", tokens: [{ token: "<directives/>", string: fs.readFileSync(‘src/config/production.js').toString() }] }
  • 9. Why we need a template engine? ❖ Don’t waste time on markup languages. ❖ Reuse the code whenever it’s possible. ❖ Indentation is the key point. ❖ Use if compilation is inevitable.
  • 10. Introducing Jade ❖ Jade, accessed from jade-lang.com, is a node template engine for HTML5 and JavaScript. ❖ Enables us to use HTML without the markup functionality. ❖ Compiles Jade code to HTML5 and JS. ❖ How?
  • 11. An example Jade code Jade
  • 12. Introducing Stylus ❖ Stylus, defined by the developers, is a expressive, robust, feature-rich CSS preprocessor. ❖ CSS without the unnecessary syntax. ❖ Enables to reuse the same CSS code for multiple rules. ❖ How?
  • 13. Example Stylus code An everyday stylus use Using Stylus with setting variables body font 12px Helvetica, Arial, sans-serif a.button -webkit-border-radius 5px -moz-border-radius 5px border-radius 5px fonts = helvetica, arial, sans-serif body padding 50px font 14px/1.4 fonts
  • 14. What now? ❖ How to compile these engines without knowing? ❖ That’s why we need Grunt. ❖ Grunt offers grunt-contrib-stylus and grunt-contrib-jade tasks to compile both of these engines.
  • 15. An example of Grunt file grunt.initConfig({ clean: { before: ['www/img', 'www/css', 'www/compiled'] }, jade: { compile: { options: { pretty: true, data: { debug: true } }, files: [{ cwd: "src", src: "**/*.jade", dest: "www", expand: true, ext: ".html" }] } }, stylus: { build: { options: { linenos: false, compress: true }, files: [{ expand: true, cwd: 'src/css', src: [ '**/*.styl' ], dest: 'www/css', ext: '.css' }] } }, });
  • 16. Sample project demo github.com/anonrig/gjs-example
  • 17. Thank you for listening. Any questions? Yagiz Nizipli yagiznizipli@me.com github.com/anonrig yagiz.nizipli.com