Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added "doctype" as alias of !!!

  • Loading branch information...
commit 9a7dfeaaa572999af015e2288edb2d946a58434d 1 parent 628a70d
TJ Holowaychuk visionmedia authored

Showing 3 changed files with 12 additions and 3 deletions. Show diff stats Hide diff stats

  1. +9 1 Readme.md
  2. +2 2 lib/lexer.js
  3. +1 0  test/jade.test.js
10 Readme.md
Source Rendered
@@ -348,7 +348,7 @@ or we could use jade's interpolation:
348 348
349 349 ### Doctypes
350 350
351   -To add a doctype simply use `!!!` followed by an optional value:
  351 +To add a doctype simply use `!!!`, or `doctype` followed by an optional value:
352 352
353 353 !!!
354 354
@@ -356,6 +356,14 @@ Will output the _transitional_ doctype, however:
356 356
357 357 !!! 5
358 358
  359 +or
  360 +
  361 + !!! html
  362 +
  363 +or
  364 +
  365 + doctype html
  366 +
359 367 Will output the _html 5_ doctype. Below are the doctypes
360 368 defined by default, which can easily be extended:
361 369
4 lib/lexer.js
@@ -219,7 +219,7 @@ Lexer.prototype = {
219 219 */
220 220
221 221 doctype: function() {
222   - return this.scan(/^!!! *(\w+)?/, 'doctype');
  222 + return this.scan(/^(?:!!!|doctype) *(\w+)?/, 'doctype');
223 223 },
224 224
225 225 /**
@@ -520,11 +520,11 @@ Lexer.prototype = {
520 520 return this.deferred()
521 521 || this.eos()
522 522 || this.pipelessText()
  523 + || this.doctype()
523 524 || this.tag()
524 525 || this.filter()
525 526 || this.each()
526 527 || this.code()
527   - || this.doctype()
528 528 || this.id()
529 529 || this.className()
530 530 || this.attrs()
1  test/jade.test.js
@@ -34,6 +34,7 @@ module.exports = {
34 34
35 35 'test doctypes': function(assert){
36 36 assert.equal('<?xml version="1.0" encoding="utf-8" ?>', render('!!! xml'));
  37 + assert.equal('<!DOCTYPE html>', render('doctype html'));
37 38 assert.equal('<!DOCTYPE html>', render('!!! 5'));
38 39 assert.equal('<!DOCTYPE html>', render('!!!', { doctype:'html' }));
39 40 assert.equal('<!DOCTYPE html>', render('!!! html', { doctype:'xml' }));

0 comments on commit 9a7dfea

Please sign in to comment.
Something went wrong with that request. Please try again.