diff --git a/README.md b/README.md index f6a18d4..2d0f182 100644 --- a/README.md +++ b/README.md @@ -461,6 +461,36 @@ These may be built using [Rake](http://rake.rubyforge.org/) and one of the follo $ rake yui3 $ rake qooxdoo +## Command line tool + +mustache.js is shipped with a node based command line tool. It might be installed as a global tool on your computer to render a mustache template of some kind + +```bash +$ npm install -g mustache +$ mustache dataView.json myTemplate.mustache > output.html + +# also supports stdin +$ cat dataView.json | mustache - myTemplate.mustache > output.html +``` + +or as a package.json `devDependency` in a build process maybe? + +```bash +$ npm install mustache --save-dev +``` +```json +{ + "scripts": { + "build": "mustache dataView.json myTemplate.mustache > public/output.html" + } +} +``` +```bash +$ npm run build +``` + +The command line tool is basically a wrapper around `Mustache.render` so you get all the aformentioned features. + ## Testing In order to run the tests you'll need to install [node](http://nodejs.org/). diff --git a/bin/mustache b/bin/mustache new file mode 100755 index 0000000..4b3f0c1 --- /dev/null +++ b/bin/mustache @@ -0,0 +1,89 @@ +#!/usr/bin/env node + +var fs = require('fs'); + +var Mustache = require('..'); +var pkg = require('../package'); + +var viewArg = process.argv[2]; +var templateArg = process.argv[3]; + +if (process.argv.indexOf('--version') > -1) { + return console.log(pkg.version); +} + +if (!templateArg || !viewArg) { + console.error('Syntax: mustache