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.