Book Image

PhoneGap Beginners Guide (third edition)

Book Image

PhoneGap Beginners Guide (third edition)

Overview of this book

Table of Contents (22 chapters)
PhoneGap Beginner's Guide Third Edition
About the Authors
About the Reviewers
Related Plugin Resources

Time for action – compiling a template using Pistachio

Create a new template file and eventually compress it using Pistachio. Follow the given steps:

  1. Open your command-line tool and move to the folders containing the template files.

  2. Type the pistachio command and specify the name of the output file and the file to compile:

    $ pistachio --out=splash-tpl.js splash-tpl.html
  3. Create a build file named, for instance, template-build.js, for the existing template to use when compressing the file with UglifyJS2, specifying the template name and the desired output filename:

        name: ‘splash-tpl',
        out: ‘splash-built.js'
  4. Run the r.js Node module from the command-line tool:

    $ r.js -o template-build.js
  5. Open the file and check its syntax and size.

What just happened?

You created a compressed version of the template file that is stored in a variable. You can now request it in the modules of the app and avoid any unnecessary XMLHttpRequest.

This technique is most beneficial when working with pretty...