to-quoted-string

0.1.1 • Public • Published

to-quoted-string NPM version

Turn source code into templates to be used as modules.

Install with npm

npm i to-quoted-string --save

Jump to CLI instructions

Usage

var toQuotedString = require('to-quoted-string');

Say you want to turn this template into a javascript module:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>{{title}}</title>
  </head>
  <body>
    {% body %}
  </body>
</html>

Pass the string

var fs = require('fs');
var str = fs.readFileSync('foo.html', 'utf8');
toQuotedString(str);

Returns:

module.exports = [
  '<!DOCTYPE html>',
  '<html lang="en">',
  '  <head>',
  '    <meta charset="UTF-8">',
  '    <title>{{title}}</title>',
  '  </head>',
  '  <body>',
  '    {% body %}',
  '  </body>',
  '</html>'
];

CLI

From the command line, specify a source file with contents to be wrapped:

to-quoted-string foo.js

Pass a destination as the second arg, or with -d|--dest

to-quoted-string foo.js bar.js

(NOTE: if no dest is specifed, _ is prepended to the source filename and the file extension is changed to .js)

Run tests

Install dev dependencies:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb on February 22, 2015.

Readme

Keywords

none

Package Sidebar

Install

npm i to-quoted-string

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • doowb
  • jonschlinkert