0.0.3 • Published 12 years ago
jsttojs-cmd v0.0.3
jsttojs
A node.js module for precompile JavaScript templates (ex. mustache or jQuery.tmpl) to one file.
You can to precompile some static mustache, hogan.js, jQuery.tmpl, underscore.js or any other templates and include them in generated javascript function that could be stitched and compressed in a single file.
And if you set the flag --watch, you can compile templates automatically!
Installation
$ npm install jsttojs -gUsage
jsttojs allows templates to be precompiled and included in javascript code
Precompile JavaScript templates.
Usage: jsttojs <input> <output> [options]
Options:
  -h, --help        output usage information
  -V, --version     output the version number
  -e, --ext <n>     extension for templates, default "jst"
  -n, --name <n>    name variable stores temapltes, default "JSTmpl"
  -w, --watch       watch files and automatic compile output file
  -r, --removebreak remove line breaks
  -a, --amd         wrap templates in AMD module
  -d, --amdalias    change AMD "define" keyword to anything
  -o, --onlyname    use as a key only file name, without directory
Examples:
  $ jsttojs templates compiled/templates/index.js --ext mustache --watchUse with grunt
Use it with grunt, install grunt-jsttojs and add this line to your project's Gruntfile:
grunt.loadNpmTasks('grunt-jsttojs');Samples
Templates:
// tamplates/index.jst
Hello world {{ username }}
second line// tamplates/video/index.jst
Hello {{ username }} on index video pageRun precompile templates
$ jsttojs templates compiled/templates/index.js --name MyGlobalVariableOutput:
// compiled/templates/index.js
window.MyGlobalVariable = {
  "index" : "Hello world {{ username }}\nsecond line",
  "video/index" : "Hello {{ username }} on index video page"
}License
Copyright (c) 2012 Alexey Kupriyanenko a.kupriyanenko@gmail.com
jsttojs is released under the MIT license.
