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

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
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
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
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
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
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
 
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
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
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 ...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
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...
 
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
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
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
 
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
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 

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