Comparing version 2.5.1 to 2.6.0
13
index.js
@@ -14,2 +14,5 @@ /*jshint node: true*/ | ||
}; | ||
var defaultProcessContent = function(content) { | ||
return content; | ||
} | ||
@@ -74,2 +77,3 @@ var MARKER = "// hbsfy compiled Handlebars template\n"; | ||
var traverse = defaultTraverse; | ||
var processContent = defaultProcessContent; | ||
@@ -94,2 +98,6 @@ opts = opts || {}; | ||
} | ||
if (opts.pc || opts.processContent) { | ||
processContent = opts.pc || opts.processContent; | ||
} | ||
} | ||
@@ -101,3 +109,4 @@ | ||
compiler: compiler, | ||
traverse: traverse | ||
traverse: traverse, | ||
processContent: processContent | ||
}); | ||
@@ -111,2 +120,3 @@ } | ||
var traverse = options.traverse; | ||
var processContent = options.processContent; | ||
@@ -120,2 +130,3 @@ var js; | ||
file = file.replace(/^\uFEFF/, ''); | ||
file = processContent(file); | ||
@@ -122,0 +133,0 @@ if (traverse) { |
{ | ||
"name": "hbsfy", | ||
"version": "2.5.1", | ||
"version": "2.6.0", | ||
"description": "Handlebars precompiler plugin for Browserify v2", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -201,5 +201,22 @@ [![Build Status](https://travis-ci.org/epeli/node-hbsfy.png?branch=master)](https://travis-ci.org/epeli/node-hbsfy) | ||
### Process output HTML string | ||
This option accepts a function which takes one argument (the template file content) and returns a string which will be used as the source for the precompiled template object. The example below removes leading and trailing spaces to shorten templates. | ||
``` | ||
hbsfy.configure({ | ||
processContent: function(content) { | ||
content = content.replace(/^[\x20\t]+/mg, '').replace(/[\x20\t]+$/mg, ''); | ||
content = content.replace(/^[\r\n]+/, '').replace(/[\r\n]*$/, '\n'); | ||
return content; | ||
} | ||
}); | ||
``` | ||
## Changelog | ||
### 2.6.0 | ||
- Add `processContent` option. [#50](https://github.com/epeli/node-hbsfy/pull/50) | ||
### 2.5.0 | ||
@@ -206,0 +223,0 @@ |
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
37208
36
757
281
15