Tip for PhoneGap Users - Modify the WWW template

This post is more than 2 years old.

Now that I've gotten comfortable with PhoneGap's command line I'm finding myself much more productive when building quick demos. The previous link will tell you more, but as a quick example, this is how I'd quickly dump out an IOS project.

"ioscreate" is not the name of a PhoneGap binary, but simply a symbolic link to the create binary from the PhoneGap iOS directory.

I then CD into the folder, run "subl www" to open the www folder in Sublime, and run "cordova/build && cordova/emulate" to run the build and emulate commands. This pops open the new application in my iOS simulator.

All of this takes about 2 seconds and works great, except for one small nit. By default, the new project has this fancy HTML.

You can't see it - but the green "Device Is Ready" is pulsating. It's very hypnotic.

What this means is that I actually spend more time "cleaning" the HTML, JavaScript, and CSS then I do actually creating the new project.

Luckily there is a quick fix for this. Given your desired platform, go to where you installed PhoneGap and you will see a "bin" folder and beneath that, a "templates" folder. There should be one folder underneath it.

See the www folder? Just edit the contents within there to your liking and the next time you create a project, your modifications will be used. Here's my version.

Ok, that's kinda boring, but I've got a nice blank HTML, JS, and CSS file ready to go in my editor.

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 Pete posted on 1/28/2013 at 1:37 PM

That's not boring at all, that's really useful.

I used the command line to build a test project last night to, I was pleasantly surprised at how quick the process was.

Changing the template... and that "subl" shortcut is really useful!

Thanks Ray.

Comment 2 by Raymond Camden posted on 1/28/2013 at 4:18 PM

You are most welcome.

Comment 3 by Don posted on 2/3/2013 at 5:07 AM

I'd like to get into mobile app dev space and am wondering how to get started, btw, I'm on Windows 7 OS platform and have not iPhone nor iPad nor smartphone. PhoneGap seems to be a development tool for mobile app, question, what iOS simulator have you used and like for Windows 7?

Thanks.

Comment 4 by Don posted on 2/3/2013 at 7:54 PM

A side note, it would be extremely beneficial to be able to view blogs in chronological order (so that one can the progression of the subject matter).

Comment 5 by Raymond Camden posted on 2/3/2013 at 8:04 PM

View what blogs?

Comment 6 by Raymond Camden posted on 2/5/2013 at 1:14 AM

To your first question, Don, I've not used an iOS Simulator on Windows. I just use it on OSX. I've got both Windows and OSX.

Comment 7 by Ville posted on 2/6/2013 at 12:33 AM

Thanks for the great tips! The default template has bugged me a long time and now I can finally change it to something more ready for testing things. And the subl tip is awesome. Now I can just type
subl .
instead of
open .
and then dragging the directory from Finder to Sublime.

Comment 8 by Raymond Camden posted on 2/6/2013 at 12:34 AM

Glad to help. As for subl - that's the one thing holding me back from switching to Brackets full time. As soon as Brackets supports that, it will be my only editor.