|
| 1 | +# SQL Template Engine |
| 2 | + |
| 3 | +[](https://david-dm.org/MitMaro/node-sql-template-engine) |
| 4 | +[](https://travis-ci.org/MitMaro/node-sql-template-engine) |
| 5 | +[](https://coveralls.io/github/MitMaro/node-sql-template-engine?branch=master) |
| 6 | +[](https://www.npmjs.com/package/@mitmaro/sql-template-engine) |
| 7 | +[](https://raw.githubusercontent.com/MitMaro/node-sql-template-engine/master/LICENSE.md) |
| 8 | +[](https://snyk.io/test/github/mitmaro/node-sql-template-engine?targetFile=package.json) |
| 9 | + |
| 10 | +## Install |
| 11 | + |
| 12 | + npm install --save @mitmaro/sql-template-engine |
| 13 | + |
| 14 | +## Documentation |
| 15 | + |
| 16 | +* [API Documentation][documentation] |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +### Creating an instance |
| 21 | + |
| 22 | +Creating a SQL Template Engine instance is very straight forward. |
| 23 | + |
| 24 | +#### JavaScript |
| 25 | +```javascript |
| 26 | +const sqlTemplateEngine = require('@mitmaro/sql-template-engine'); |
| 27 | +const serviceManager = sqlTemplateEngine({ |
| 28 | + // options |
| 29 | +}); |
| 30 | +``` |
| 31 | + |
| 32 | +#### TypeScript |
| 33 | +```typescript |
| 34 | +import sqlTemplateEngine from '@mitmaro/sql-template-engine'; |
| 35 | +const serviceManager = sqlTemplateEngine({ |
| 36 | + // options |
| 37 | +}); |
| 38 | +``` |
| 39 | + |
| 40 | +#### Options |
| 41 | + |
| 42 | +|Name |Type |Description |Default | |
| 43 | +|-----------------|--------------------------|----------------------------------------------------------------|--------------------------| |
| 44 | +|cache |`AbstractSyntaxTreeCache` |A custom abstract syntax tree cache |Memory | |
| 45 | +|epsilon |`number` |The allowed error due to rounding in floating point comparisons |`Number.EPSILON` | |
| 46 | +|fileEncoding |`string` |The file encoding for template files |UTF-8 | |
| 47 | +|rootPath |`string` |The root directory for looking for template files |Current working directory | |
| 48 | +|maximumCallDepth |`number` |The maximum depth of nested includes |64 | |
| 49 | + |
| 50 | +### Invoking a template file |
| 51 | + |
| 52 | +```javascript |
| 53 | +const result = await serviceManager.invokeTemplateFile('template.tpl', {foo: 'bar'}); |
| 54 | +``` |
| 55 | + |
| 56 | +## Development |
| 57 | + |
| 58 | +Development is done using Node 8 and NPM 5, and tested against both Node 8 and Node 10. To get started |
| 59 | + |
| 60 | +* Install Node 8 from [NodeJS.org][node] or using [nvm] |
| 61 | +* Clone the repository using `git clone git@github.com:MitMaro/node-sql-template-engine.git` |
| 62 | +* `cd node-sql-template-engine` |
| 63 | +* Install the dependencies `npm install` |
| 64 | +* Make changes, add tests, etc. |
| 65 | +* Run linting and test suite using `npm run test` |
| 66 | +* Build using `npm run build` |
| 67 | + |
| 68 | +## License |
| 69 | + |
| 70 | +This project is released under the ISC license. See [LICENSE](LICENSE.md). |
| 71 | + |
| 72 | + |
| 73 | +[documentation]: http://www.mitmaro.ca/node-service-manager/ |
| 74 | +[LICENSE]:LICENSE |
| 75 | +[node]:https://nodejs.org/en/download/ |
| 76 | +[nvm]:https://github.com/creationix/nvm#installation |
0 commit comments