Tuesday, July 14, 2015

Building a Source Code Generator with AngularJS

If you are looking for generating scaffold for AngularJS, this is not what this blog post about. This blog post is about generate source code with AngularJS.

The principle of creating source code generators is pretty simple (details here): a model, a template, and a driver. Given:
  1. HTML5 can access to local files as the data model
  2. AngularJS has its template language
  3. JavaScript is the driver
The following code in JSFiddle takes a tab delimited (3 columns) file to generate a Oracle script:


The syntax highlighting is done by SHJS.

Since it takes any JavaScript object as the model, other potential input formats are JSON and XML (with aid of some library). This is a lightweight cross-platform source code generator.