
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
to-quoted-string
Advanced tools
Turn source code into templates to be used as modules.
npm i to-quoted-string --save
Jump to CLI instructions
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>'
];
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)
Install dev dependencies:
npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb on February 22, 2015.
FAQs
Turn source code into templates to be used as modules.
We found that to-quoted-string demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.