Permalink
Browse files

Added "doctype" as alias of !!!

  • Loading branch information...
1 parent 628a70d commit 9a7dfeaaa572999af015e2288edb2d946a58434d @tj tj committed Jun 1, 2011
Showing with 12 additions and 3 deletions.
  1. +9 −1 Readme.md
  2. +2 −2 lib/lexer.js
  3. +1 −0 test/jade.test.js
View
@@ -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:
View
@@ -219,7 +219,7 @@ Lexer.prototype = {
*/
doctype: function() {
- return this.scan(/^!!! *(\w+)?/, 'doctype');
+ return this.scan(/^(?:!!!|doctype) *(\w+)?/, 'doctype');
},
/**
@@ -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()
View
@@ -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' }));

0 comments on commit 9a7dfea

Please sign in to comment.