Showing posts from July, 2016

RequireJS: More with modules - Templates

Find the previous episode here.

Checkout the part 3 branch
git checkout -b part3.0 origin/part3.0
We have created the routing and added a test module to the application. Lets try to add more to module.

        Am going to use RequireJS "Text" plugin for templating along with  Underscore.js and Jquery
    An AMD loader plugin for requireJS to load text resouces. We will load html using text.
    "Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects."
underscore provides a powerfull templating option. You could try lodash also which is a fork of UnderscoreJS

Let's do some coding now. First we need to create a template in html.
We will extract this code from index.html and will create a new html in modules/home/templates/home.html

<div> <ul> <li><a href="#home">Home</a></li> <li><a href="#em…