-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
32 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# ignore any vim files: | ||
*.sw[a-z] | ||
vim/.netrwhist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"author": "TJ Holowaychuk <[email protected]>", | ||
"keywords": ["template", "engine", "ejs"], | ||
"devDependencies": { | ||
"expresso" "0.9.2" | ||
} | ||
"expresso": "0.9.2" | ||
}, | ||
"main": "./lib/ejs.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,95 +3,96 @@ | |
* Module dependencies. | ||
*/ | ||
|
||
var ejs = require('ejs'); | ||
var ejs = require('../') | ||
, assert = require('assert'); | ||
|
||
module.exports = { | ||
'test .version': function(assert){ | ||
'test .version': function(){ | ||
assert.ok(/^\d+\.\d+\.\d+$/.test(ejs.version), 'Test .version format'); | ||
}, | ||
|
||
'test html': function(assert){ | ||
'test html': function(){ | ||
assert.equal('<p>yay</p>', ejs.render('<p>yay</p>')); | ||
}, | ||
|
||
'test buffered code': function(assert){ | ||
'test buffered code': function(){ | ||
var html = '<p>tj</p>', | ||
str = '<p><%= name %></p>', | ||
locals = { name: 'tj' }; | ||
assert.equal(html, ejs.render(str, { locals: locals })); | ||
}, | ||
|
||
'test unbuffered code': function(assert){ | ||
'test unbuffered code': function(){ | ||
var html = '<p>tj</p>', | ||
str = '<% if (name) { %><p><%= name %></p><% } %>', | ||
locals = { name: 'tj' }; | ||
assert.equal(html, ejs.render(str, { locals: locals })); | ||
}, | ||
|
||
'test `scope` option': function(assert){ | ||
'test `scope` option': function(){ | ||
var html = '<p>tj</p>', | ||
str = '<p><%= this %></p>'; | ||
assert.equal(html, ejs.render(str, { scope: 'tj' })); | ||
}, | ||
|
||
'test escaping': function(assert){ | ||
'test escaping': function(){ | ||
assert.equal('<script>', ejs.render('<%= "<script>" %>')); | ||
assert.equal('<script>', ejs.render('<%- "<script>" %>')); | ||
}, | ||
|
||
'test newlines': function(assert){ | ||
'test newlines': function(){ | ||
var html = '\n<p>tj</p>\n<p>[email protected]</p>', | ||
str = '<% if (name) { %>\n<p><%= name %></p>\n<p><%= email %></p><% } %>', | ||
locals = { name: 'tj', email: '[email protected]' }; | ||
assert.equal(html, ejs.render(str, { locals: locals })); | ||
}, | ||
|
||
'test single quotes': function(assert){ | ||
'test single quotes': function(){ | ||
var html = '<p>WAHOO</p>', | ||
str = "<p><%= up('wahoo') %></p>", | ||
locals = { up: function(str){ return str.toUpperCase(); }}; | ||
assert.equal(html, ejs.render(str, { locals: locals })); | ||
}, | ||
|
||
'test single quotes in the html': function(assert){ | ||
'test single quotes in the html': function(){ | ||
var html = '<p>WAHOO that\'s cool</p>', | ||
str = '<p><%= up(\'wahoo\') %> that\'s cool</p>', | ||
locals = { up: function(str){ return str.toUpperCase(); }}; | ||
assert.equal(html, ejs.render(str, { locals: locals })); | ||
}, | ||
|
||
'test multiple single quotes': function(assert) { | ||
'test multiple single quotes': function() { | ||
var html = "<p>couldn't shouldn't can't</p>", | ||
str = "<p>couldn't shouldn't can't</p>"; | ||
assert.equal(html, ejs.render(str)); | ||
}, | ||
|
||
'test single quotes inside tags': function(assert) { | ||
'test single quotes inside tags': function() { | ||
var html = '<p>string</p>', | ||
str = "<p><%= 'string' %></p>"; | ||
assert.equal(html, ejs.render(str)); | ||
}, | ||
|
||
'test back-slashes in the document': function(assert) { | ||
'test back-slashes in the document': function() { | ||
var html = "<p>backslash: '\\'</p>", | ||
str = "<p>backslash: '\\'</p>"; | ||
assert.equal(html, ejs.render(str)); | ||
}, | ||
|
||
'test double quotes': function(assert){ | ||
'test double quotes': function(){ | ||
var html = '<p>WAHOO</p>', | ||
str = '<p><%= up("wahoo") %></p>', | ||
locals = { up: function(str){ return str.toUpperCase(); }}; | ||
assert.equal(html, ejs.render(str, { locals: locals })); | ||
}, | ||
|
||
'test multiple double quotes': function(assert) { | ||
'test multiple double quotes': function() { | ||
var html = '<p>just a "test" wahoo</p>', | ||
str = '<p>just a "test" wahoo</p>'; | ||
assert.equal(html, ejs.render(str)); | ||
}, | ||
|
||
'test whitespace': function(assert){ | ||
'test whitespace': function(){ | ||
var html = '<p>foo</p>', | ||
str = '<p><%="foo"%></p>'; | ||
assert.equal(html, ejs.render(str)); | ||
|
@@ -101,7 +102,7 @@ module.exports = { | |
assert.equal(html, ejs.render(str, { locals: { bar: 'foo' }})); | ||
}, | ||
|
||
'test custom tags': function(assert){ | ||
'test custom tags': function(){ | ||
var html = '<p>foo</p>', | ||
str = '<p>{{= "foo" }}</p>'; | ||
|
||
|
@@ -119,7 +120,7 @@ module.exports = { | |
})); | ||
}, | ||
|
||
'test custom tags over 2 chars': function(assert){ | ||
'test custom tags over 2 chars': function(){ | ||
var html = '<p>foo</p>', | ||
str = '<p>{{{{= "foo" }>>}</p>'; | ||
|
||
|
@@ -137,7 +138,7 @@ module.exports = { | |
})); | ||
}, | ||
|
||
'test global custom tags': function(assert){ | ||
'test global custom tags': function(){ | ||
var html = '<p>foo</p>', | ||
str = '<p>{{= "foo" }}</p>'; | ||
ejs.open = '{{'; | ||
|
@@ -147,7 +148,7 @@ module.exports = { | |
delete ejs.close; | ||
}, | ||
|
||
'test iteration': function(assert){ | ||
'test iteration': function(){ | ||
var html = '<p>foo</p>', | ||
str = '<% for (var key in items) { %>' | ||
+ '<p><%= items[key] %></p>' | ||
|
@@ -169,7 +170,7 @@ module.exports = { | |
})); | ||
}, | ||
|
||
'test filter support': function(assert){ | ||
'test filter support': function(){ | ||
var html = 'Zab', | ||
str = '<%=: items | reverse | first | reverse | capitalize %>'; | ||
assert.equal(html, ejs.render(str, { | ||
|
@@ -179,7 +180,7 @@ module.exports = { | |
})); | ||
}, | ||
|
||
'test filter argument support': function(assert){ | ||
'test filter argument support': function(){ | ||
var html = 'tj, guillermo', | ||
str = '<%=: users | map:"name" | join:", " %>'; | ||
assert.equal(html, ejs.render(str, { | ||
|
@@ -192,7 +193,7 @@ module.exports = { | |
})); | ||
}, | ||
|
||
'test sort_by filter': function(assert){ | ||
'test sort_by filter': function(){ | ||
var html = 'tj', | ||
str = '<%=: users | sort_by:"name" | last | get:"name" %>'; | ||
assert.equal(html, ejs.render(str, { | ||
|
@@ -206,7 +207,7 @@ module.exports = { | |
})); | ||
}, | ||
|
||
'test custom filters': function(assert){ | ||
'test custom filters': function(){ | ||
var html = 'Welcome Tj Holowaychuk', | ||
str = '<%=: users | first | greeting %>'; | ||
|
||
|
@@ -223,7 +224,7 @@ module.exports = { | |
})); | ||
}, | ||
|
||
'test useful stack traces': function(assert){ | ||
'test useful stack traces': function(){ | ||
var str = [ | ||
"A little somethin'", | ||
"somethin'", | ||
|
@@ -243,7 +244,7 @@ module.exports = { | |
} | ||
}, | ||
|
||
'test useful stack traces multiline': function(assert){ | ||
'test useful stack traces multiline': function(){ | ||
var str = [ | ||
"A little somethin'", | ||
"somethin'", | ||
|