It's original purpose, was to read in an .html file, and output it as a series of document.write() statements. This is useful when creating bookmarklets. You can code your .html page, then run tojs on it. Now all your bookmarklet has to do is include a script tag that points to the file you created with tojs.
Since version 1.2.0, tojs was converted to a node.js project, and now supports a few different input/output formats. To see the new options, check out the Usage and Options sections below.
npm install -g tojs
tojs [options] <input_filenames> tojs [options] <input_filenames> > <output_filename> echo -e "one\ntwo\nthree" | tojs [options]
-h, --help output usage information -v, --version output the version number -i, --input [type] The type of input [plain|js|jsvar|docwrite] -o, --output [type] The type of input [plain|js|jsvar|docwrite] -n, --name [name] If output is "jsvar", this is the variable name --oneline Force output to be on one line only --single-quotes Use single-quotes instead of double-quotes for output --no-var var keyword will not be included in output --no-open document.open() will not be included in output --no-close document.close() will not be included in output
converting to a node.js project so installation instructions have changed
command line options have changed
now supports the following input/output types:
can now pipe data from stdin or use a list of files as input (similar to the unix cat command)
fixing formatting of help text
adding 2 new command line options
-o | --no-open -- don't print the document.open() statement
-c | --no-close -- don't print the document.close() statement