Skip to content

Commit

Permalink
add test for data
Browse files Browse the repository at this point in the history
  • Loading branch information
Floby committed Mar 29, 2013
1 parent d9bf9e0 commit 86badab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Template.js
Expand Up @@ -54,7 +54,7 @@ Template.prototype.run = function run() {
this.getScript(function(err, script) {
if(err) return self.emit(err);
try {
script(print, include);
script(print, include, self.data());
}
catch(e) {
self.emit('error', e);
Expand Down
1 change: 1 addition & 0 deletions test/templates/data.tpl
@@ -0,0 +1 @@
<%= data.str %>
15 changes: 15 additions & 0 deletions test/test-20-data.js
@@ -0,0 +1,15 @@
var Sink = require('./sink');
var blue = require('../');

exports.testOneFile = function(test) {
var sink = Sink();
var t = new blue.Template(__dirname + '/templates/data.tpl');
t.data({
str: "hello world!"
})
t.pipe(sink).on('data', function(data) {
test.equal(data.trim(), 'hello world!', "sink data should be identical");
test.done();
});
}

0 comments on commit 86badab

Please sign in to comment.