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>
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?
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.