This powerful small JS library allows you to create a fully valid CPCL document for output to a Zebra printer (MZ320 / iMZ320 plus many more).
Download and launch the Zebra.html file so you can see how it's built. As you build it'll display the JS code equivalent and the output in both raw CPCL and base64 string. Also it includes the ability of incorporating images to be printed converting img / canvas based image data into raw IO CPCL output including dealing with
I personally use this on the iPhone for printing to a Zebra printer via Mobiprint from a home screen link based web app.
CPCL information can be found here: http://www.zebra.com/content/dam/zebra/manuals/en-us/printer/cpcl-pm-en.pdf
Currently limited to Zebra 3" format printers using CPCL.
If people express interest (or if you fork it), I'll build for different width sizes.