Skip to content

Commit

Permalink
Added "doctype" as alias of !!!
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jun 1, 2011
1 parent 628a70d commit 9a7dfea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,22 @@ or we could use jade's interpolation:

### Doctypes

To add a doctype simply use `!!!` followed by an optional value:
To add a doctype simply use `!!!`, or `doctype` followed by an optional value:

!!!

Will output the _transitional_ doctype, however:

!!! 5

or

!!! html

or

doctype html

Will output the _html 5_ doctype. Below are the doctypes
defined by default, which can easily be extended:

Expand Down
4 changes: 2 additions & 2 deletions lib/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Lexer.prototype = {
*/

doctype: function() {
return this.scan(/^!!! *(\w+)?/, 'doctype');
return this.scan(/^(?:!!!|doctype) *(\w+)?/, 'doctype');
},

/**
Expand Down Expand Up @@ -520,11 +520,11 @@ Lexer.prototype = {
return this.deferred()
|| this.eos()
|| this.pipelessText()
|| this.doctype()
|| this.tag()
|| this.filter()
|| this.each()
|| this.code()
|| this.doctype()
|| this.id()
|| this.className()
|| this.attrs()
Expand Down
1 change: 1 addition & 0 deletions test/jade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {

'test doctypes': function(assert){
assert.equal('<?xml version="1.0" encoding="utf-8" ?>', render('!!! xml'));
assert.equal('<!DOCTYPE html>', render('doctype html'));
assert.equal('<!DOCTYPE html>', render('!!! 5'));
assert.equal('<!DOCTYPE html>', render('!!!', { doctype:'html' }));
assert.equal('<!DOCTYPE html>', render('!!! html', { doctype:'xml' }));
Expand Down

0 comments on commit 9a7dfea

Please sign in to comment.