🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

to-quoted-string

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-quoted-string

Turn source code into templates to be used as modules.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 23 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts