Permalink
Browse files

Added Buffer support to render()

  • Loading branch information...
1 parent 9a3cdf4 commit 27534d9784f1ef56f55e311c65572790ba5eaa1d @tj tj committed Jul 27, 2010
Showing with 10 additions and 2 deletions.
  1. +4 −1 lib/jade.js
  2. +6 −1 test/jade.test.js
View
5 lib/jade.js
@@ -771,7 +771,7 @@ function parse(str, options){
* - `filename` Used in exceptions, and required by `cache`
* - `cache` Cache intermediate JavaScript in memory keyed by `filename`
*
- * @param {String} str
+ * @param {String|Buffer} str
* @param {Object} options
* @return {String}
* @api public
@@ -782,6 +782,9 @@ exports.render = function(str, options){
options = options || {},
filename = options.filename;
+ // Accept Buffers
+ str = String(str);
+
// Cache support
if (options.cache) {
if (filename) {
View
7 test/jade.test.js
@@ -3,7 +3,8 @@
* Module dependencies.
*/
-var jade = require('jade');
+var jade = require('jade'),
+ Buffer = require('buffer').Buffer;
// Shortcut
@@ -29,6 +30,10 @@ module.exports = {
assert.equal("Jade:1\n 1. ':doesNotExist'\n\nunknown filter \":doesNotExist\"", err.message);
},
+ 'test Buffers': function(assert){
+ assert.equal('<p>foo</p>', render(new Buffer('p foo')));
+ },
+
'test line endings': function(assert){
var str = [
'p',

0 comments on commit 27534d9

Please sign in to comment.