PhoneGap CLI and Templates

This post is more than 2 years old.

A few days ago the PhoneGap team announced an update to the CLI: PhoneGap CLI 5.0.0 Released!. To be honest, I don't typically make use of the PhoneGap CLI as I mostly use either Cordova or Ionic. However, I missed an earlier update that I think is pretty cool (and it is one I was able to help out with) - template support.

When creating a PhoneGap project, you can request a template to be used instead of the default PhoneGap project. You've been able to copy from a directory for a while now (using --copy-from or --link-to), but this new feature lets you specify from a set of templates that might be useful for seeding a new project.

To see what templates exist, you execute: phonegap template list (you can also replace template with recipe):

shot1

There are only four templates so far, but more will be coming in the future. I've said before that I'm not a fan of the default template used by both Cordova and PhoneGap, so I'm happy to see blank as an option. The jQuery Mobile template is one I built. To use a template, you simply use --template name when creating your application.

shot2

My template includes the latest jQuery Mobile assets, and includes JavaScript code that will fire a method when both jQuery Mobile and PhoneGap is ready to run. If you're curious, you can see the repo here: https://github.com/cfjedimaster/jQuery-Mobile-Starter.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Michael posted on 5/1/2015 at 11:45 PM

So now we can't use a hyphen in our cordova file name? I get App id contains a reserved word, or is not a valid identifier.

cordova create SBCERAApp org.sbcera.sbcera-application-ios SBCERA
App id contains a reserved word, or is not a valid identifier.

I have been using this file name for years and it is in all my apple profiles, push notifications, etc.

Comment 2 (In reply to #1) by Raymond Camden posted on 5/2/2015 at 1:20 PM

Best I can suggest is filing a bug report for it!

Comment 3 by Juan David Nicholls posted on 5/7/2015 at 2:49 PM

jQuery Mobile :( Better Ionic Framework...

Comment 4 (In reply to #3) by Raymond Camden posted on 5/7/2015 at 3:00 PM

I do think Ionic is better. However, jQuery Mobile isn't bad, and it is easier for folks to pick up, especially if they don't know Angular.