Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

underscore-template-loader

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

underscore-template-loader - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

42

index.js
var _ = require('underscore');
var loaderUtils = require('loader-utils');
var path = require('path');
var fs = require('fs');
function resolveContent(content, root) {
var includeRegex = /<!--include\s+([\/\w\.]*?[\w]+\.[\w]+)-->/g;
var matches = includeRegex.exec(content);
while (matches != null) {
var file = loaderUtils.urlToRequest(matches[1]);
var basename = path.basename(file);
var dirname = path.join(root, path.dirname(file));
var rawContent = readFile(basename, dirname);
content = content.replace(matches[0], rawContent);
matches = includeRegex.exec(content);
}
return content;
}
function readFile(filepath, root) {
var self = readFile;
if (typeof(self.buffer) == "undefined") {
self.buffer = {};
}
if (filepath in self.buffer) {
return self.buffer[filepath];
}
var content = resolveContent(fs.readFileSync(path.join(root, filepath), 'utf8'), root);
self.buffer[filepath] = content;
return self.buffer[filepath];
}
module.exports = function(content) {
this.cacheable && this.cacheable();
var callback = this.async();
content = resolveContent(content, "./");
var fn = _.template(content);
callback(null, "module.exports = " + fn.source + ";");
}
callback(null, "module.exports = " + fn + ";");
};
module.exports._ = _;

11

package.json
{
"name": "underscore-template-loader",
"version": "0.1.0",
"version": "0.2.0",
"description": "A Underscore template loader for Webpack",

@@ -8,3 +8,3 @@ "main": "index.js",

"bugs": {
"url": "https://github.com/emaphp/underscore-template-loader/isuues"
"url": "https://github.com/emaphp/underscore-template-loader/issues"
},

@@ -15,4 +15,9 @@ "author": {

},
"repository": {
"type": "git",
"url": "https://github.com/emaphp/underscore-template-loader.git"
},
"dependencies": {
"underscore": "^1.6.0"
"underscore": "^1.6.0",
"loader-utils": "^0.2.5"
},

@@ -19,0 +24,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc