Skip to content

Commit

Permalink
Fixed empty strings support. Closes pugjs#223
Browse files Browse the repository at this point in the history
also using ../ instead of jade now since
npm is messing shit up
  • Loading branch information
tj committed Jun 21, 2011
1 parent 05d45a6 commit b7dd7d9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ UGLIFY_FLAGS = --no-mangle

test:
@./node_modules/.bin/expresso \
-I lib \
-I node_modules \
$(TESTS)

Expand Down
2 changes: 1 addition & 1 deletion lib/jade.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function attrs(obj){
for (var i = 0; i < len; ++i) {
var key = keys[i]
, val = obj[key];
if (typeof val === 'boolean' || val === '' || val == null) {
if ('boolean' == typeof val || null == val) {
if (val) {
terse
? buf.push(key)
Expand Down
2 changes: 1 addition & 1 deletion test/filters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Module dependencies.
*/

var jade = require('jade'),
var jade = require('../'),
Compiler = jade.Compiler,
render = jade.render,
nodes = jade.nodes;
Expand Down
9 changes: 4 additions & 5 deletions test/jade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* Module dependencies.
*/

var jade = require('jade')
, Buffer = require('buffer').Buffer
var jade = require('../')
, ENOENT;

// COMPAT:
Expand Down Expand Up @@ -339,7 +338,7 @@ module.exports = {
assert.equal('<p>click\n<a>Google</a>.\n</p>', render('p\n | click\n a Google\n | .'));
assert.equal('<p>(parens)</p>', render('p (parens)'));
assert.equal('<p foo="bar">(parens)</p>', render('p(foo="bar") (parens)'));
assert.equal('<option>-- (optional) foo --</option>', render('option(value="") -- (optional) foo --'));
assert.equal('<option value="">-- (optional) foo --</option>', render('option(value="") -- (optional) foo --'));
},

'test tag text block': function(assert){
Expand Down Expand Up @@ -398,7 +397,6 @@ module.exports = {
assert.equal('<input type="checkbox"/>', render('input(type="checkbox", checked= false)'));
assert.equal('<input type="checkbox"/>', render('input(type="checkbox", checked= null)'));
assert.equal('<input type="checkbox"/>', render('input(type="checkbox", checked= undefined)'));
assert.equal('<input type="checkbox"/>', render('input(type="checkbox", checked= "")'));

assert.equal('<img src="/foo.png"/>', render('img(src="/foo.png")'), 'Test attr =');
assert.equal('<img src="/foo.png"/>', render('img(src = "/foo.png")'), 'Test attr = whitespace');
Expand Down Expand Up @@ -477,12 +475,13 @@ module.exports = {
assert.equal('<p></p>', render('p(id= name)', { locals: { name: undefined }}));
assert.equal('<p></p>', render('p(id= name)', { locals: { name: null }}));
assert.equal('<p></p>', render('p(id= name)', { locals: { name: false }}));
assert.equal('<p></p>', render('p(id= name)', { locals: { name: '' }}));
assert.equal('<p id=""></p>', render('p(id= name)', { locals: { name: '' }}));
assert.equal('<p id="tj"></p>', render('p(id= name)', { locals: { name: 'tj' }}));
assert.equal('<p id="default"></p>', render('p(id= name || "default")', { locals: { name: null }}));
assert.equal('<p id="something"></p>', render("p(id= 'something')", { locals: { name: null }}));
assert.equal('<p id="something"></p>', render("p(id = 'something')", { locals: { name: null }}));
assert.equal('<p id="foo"></p>', render("p(id= (true ? 'foo' : 'bar'))"));
assert.equal('<option value="">Foo</option>', render("option(value='') Foo"));
},

'test code attrs class': function(assert){
Expand Down

0 comments on commit b7dd7d9

Please sign in to comment.