underscore-template-loader
Advanced tools
Comparing version 0.2.5 to 0.2.6
21
index.js
@@ -8,16 +8,16 @@ var _ = require('underscore'); | ||
var includeRegex = /<!--include\s+([\/\w\.]*?[\w]+\.[\w]+)-->/g; | ||
var readFile = function(filepath, root) { | ||
var self = readFile; | ||
self.buffer = self.buffer || {}; | ||
if (filepath in self.buffer) | ||
return self.buffer[filepath]; | ||
var content = readContent(fs.readFileSync(path.join(root, filepath), 'utf8'), root); | ||
var content = readContent(fs.readFileSync(path.join(root, filepath), 'utf8'), root); | ||
self.buffer[filepath] = content; | ||
return self.buffer[filepath]; | ||
}; | ||
var readContent = function(content, root) { | ||
var readContent = function(content, root) { | ||
var matches = includeRegex.exec(content); | ||
@@ -34,4 +34,11 @@ | ||
}; | ||
return function(content) { | ||
if (this.query.length) { | ||
var query = loaderUtils.parseQuery(this.query); | ||
_.each(query, function(value, key){ | ||
_.templateSettings[key] = new RegExp(value, 'g'); | ||
}); | ||
}; | ||
this.cacheable && this.cacheable(); | ||
@@ -38,0 +45,0 @@ var callback = this.async(); |
{ | ||
"name": "underscore-template-loader", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "A Underscore template loader for Webpack", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -26,2 +26,21 @@ underscore-template-loader | ||
``` | ||
<br/> | ||
**Set underscore template settings** | ||
```javascript | ||
module.exports = { | ||
//... | ||
loaders: [ | ||
//... | ||
{ | ||
test: /\.html/, | ||
loader: "underscore-template-loader", | ||
query: { | ||
interpolate : '\\{\\[(.+?)\\]\\}', | ||
evaluate: '\\{%([\\s\\S]+?)%\\}', | ||
escape : '\\{\\{(.+?)\\}\\}' | ||
} | ||
} | ||
] | ||
}; | ||
``` | ||
@@ -28,0 +47,0 @@ <br/> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4907
40
77