diff --git a/lib/compiler.js b/lib/compiler.js
index 0ceb8da81..03a39bbba 100644
--- a/lib/compiler.js
+++ b/lib/compiler.js
@@ -71,6 +71,9 @@ Compiler.prototype = {
setDoctype: function(name){
name = name || 'default';
+ if (name.toLowerCase() === '5') {
+ throw new Error('`doctype 5` is deprecated, you must now use `doctype html`');
+ }
this.doctype = doctypes[name.toLowerCase()] || '';
this.terse = this.doctype.toLowerCase() == '';
this.xml = 0 == this.doctype.indexOf(''
- , 'default': ''
+ 'default': ''
, 'xml': ''
, 'transitional': ''
, 'strict': ''
diff --git a/lib/lexer.js b/lib/lexer.js
index 4c40034ed..07597cd03 100644
--- a/lib/lexer.js
+++ b/lib/lexer.js
@@ -253,7 +253,10 @@ Lexer.prototype = {
*/
doctype: function() {
- return this.scan(/^(?:!!!|doctype) *([^\n]+)?/, 'doctype');
+ if (this.scan(/^!!! *([^\n]+)?/, 'doctype')) {
+ throw new Error('`!!!` is deprecated, you must now use `doctype`');
+ }
+ return this.scan(/^(?:doctype) *([^\n]+)?/, 'doctype');
},
/**
diff --git a/test/cases/doctype.default.jade b/test/cases/doctype.default.jade
index 73c908d5e..992885e45 100644
--- a/test/cases/doctype.default.jade
+++ b/test/cases/doctype.default.jade
@@ -1,4 +1,4 @@
-!!!
+doctype
html
body
h1 Title
\ No newline at end of file
diff --git a/test/cases/escape-test.jade b/test/cases/escape-test.jade
index 00290e42e..168c549a0 100644
--- a/test/cases/escape-test.jade
+++ b/test/cases/escape-test.jade
@@ -1,4 +1,4 @@
-!!! 5
+doctype html
html
head
title escape-test
diff --git a/test/cases/html5.jade b/test/cases/html5.jade
index 24223cf8f..8dc68e264 100644
--- a/test/cases/html5.jade
+++ b/test/cases/html5.jade
@@ -1,4 +1,4 @@
-doctype 5
+doctype html
input(type='checkbox', checked)
input(type='checkbox', checked=true)
input(type='checkbox', checked=false)
\ No newline at end of file
diff --git a/test/error.reporting.js b/test/error.reporting.js
index 2ad85741f..17b45b943 100644
--- a/test/error.reporting.js
+++ b/test/error.reporting.js
@@ -105,4 +105,16 @@ describe('error reporting', function () {
});
});
});
+ describe('deprecated features', function () {
+ it('deprecates `!!!` in favour of `doctype`', function () {
+ var err = getError('!!! 5', {filename: 'test.jade'})
+ assert(/test\.jade:1/.test(err.message))
+ assert(/`!!!` is deprecated, you must now use `doctype`/.test(err.message))
+ });
+ it('deprecates `doctype 5` in favour of `doctype html`', function () {
+ var err = getError('doctype 5', {filename: 'test.jade'})
+ assert(/test\.jade:1/.test(err.message))
+ assert(/`doctype 5` is deprecated, you must now use `doctype html`/.test(err.message))
+ });
+ });
});
diff --git a/test/jade.test.js b/test/jade.test.js
index df815a111..2ac0c292a 100644
--- a/test/jade.test.js
+++ b/test/jade.test.js
@@ -23,12 +23,12 @@ describe('jade', function(){
describe('.compile()', function(){
it('should support doctypes', function(){
- assert.equal('', jade.render('!!! xml'));
+ assert.equal('', jade.render('doctype xml'));
assert.equal('', jade.render('doctype html'));
assert.equal('', jade.render('doctype foo bar baz'));
- assert.equal('', jade.render('!!! 5'));
- assert.equal('', jade.render('!!!', { doctype:'html' }));
- assert.equal('', jade.render('!!! html', { doctype:'xml' }));
+ assert.equal('', jade.render('doctype html'));
+ assert.equal('', jade.render('doctype', { doctype:'html' }));
+ assert.equal('', jade.render('doctype html', { doctype:'xml' }));
assert.equal('', jade.render('html'));
assert.equal('', jade.render('html', { doctype:'html' }));
assert.equal('', jade.render('!!! 5\ninput(type="checkbox", checked)'));
- assert.equal('', jade.render('!!! 5\ninput(type="checkbox", checked=true)'));
- assert.equal('', jade.render('!!! 5\ninput(type="checkbox", checked= false)'));
+ assert.equal('', jade.render('doctype html\ninput(type="checkbox", checked)'));
+ assert.equal('', jade.render('doctype html\ninput(type="checkbox", checked=true)'));
+ assert.equal('', jade.render('doctype html\ninput(type="checkbox", checked= false)'));
});
it('should support multi-line attrs', function(){