Comparing version 0.11.1 to 0.12.0
0.12.0 / 2011-06-03 | ||
================== | ||
* Added `doctype` as alias of `!!!` | ||
* Added; doctype value is now case-insensitive | ||
* Added attribute interpolation support | ||
* Fixed; retain original indentation spaces in text blocks | ||
0.11.1 / 2011-06-01 | ||
@@ -3,0 +11,0 @@ ================== |
@@ -85,3 +85,3 @@ | ||
setDoctype: function(name){ | ||
var doctype = doctypes[name || 'default']; | ||
var doctype = doctypes[(name || 'default').toLowerCase()]; | ||
if (!doctype) throw new Error('unknown doctype "' + name + '"'); | ||
@@ -88,0 +88,0 @@ this.doctype = doctype; |
@@ -22,3 +22,3 @@ | ||
exports.version = '0.11.1'; | ||
exports.version = '0.12.0'; | ||
@@ -25,0 +25,0 @@ /** |
@@ -222,3 +222,3 @@ | ||
doctype: function() { | ||
return this.scan(/^!!! *(\w+)?/, 'doctype'); | ||
return this.scan(/^(?:!!!|doctype) *(\w+)?/, 'doctype'); | ||
}, | ||
@@ -302,2 +302,8 @@ | ||
function interpolate(attr) { | ||
return attr.replace(/#\{([^}]+)\}/g, function(_, expr){ | ||
return "' + (" + expr + ") + '"; | ||
}); | ||
} | ||
this.consume(index + 1); | ||
@@ -324,3 +330,3 @@ tok.attrs = {}; | ||
? true | ||
: val; | ||
: interpolate(val); | ||
key = val = ''; | ||
@@ -462,3 +468,3 @@ } | ||
this.indentStack.unshift(indents); | ||
tok = this.tok('indent'); | ||
tok = this.tok('indent', indents); | ||
// newline | ||
@@ -521,2 +527,3 @@ } else { | ||
|| this.pipelessText() | ||
|| this.doctype() | ||
|| this.tag() | ||
@@ -526,3 +533,2 @@ || this.filter() | ||
|| this.code() | ||
|| this.doctype() | ||
|| this.id() | ||
@@ -529,0 +535,0 @@ || this.className() |
@@ -298,7 +298,8 @@ | ||
parseTextBlock: function(textIndent){ | ||
textIndent = textIndent || ""; | ||
parseTextBlock: function(){ | ||
var text = new nodes.Text; | ||
text.line = this.line(); | ||
this.expect('indent'); | ||
var spaces = this.expect('indent').val; | ||
if (null == this._spaces) this._spaces = spaces; | ||
var indent = Array(spaces - this._spaces + 1).join(' '); | ||
while ('outdent' != this.peek().type) { | ||
@@ -312,3 +313,3 @@ switch (this.peek().type) { | ||
text.push('\\n'); | ||
this.parseTextBlock(textIndent + " ").nodes.forEach(function(node){ | ||
this.parseTextBlock().nodes.forEach(function(node){ | ||
text.push(node); | ||
@@ -319,5 +320,6 @@ }); | ||
default: | ||
text.push(textIndent + this.advance().val); | ||
text.push(indent + this.advance().val); | ||
} | ||
} | ||
this._spaces = null; | ||
this.expect('outdent'); | ||
@@ -324,0 +326,0 @@ return text; |
{ | ||
"name": "jade", | ||
"description": "Jade template engine", | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -17,3 +17,4 @@ "repository": "git://github.com/visionmedia/jade", | ||
}, | ||
"scripts" : { "prepublish" : "npm prune" }, | ||
"engines": { "node": ">= 0.1.98" } | ||
} |
@@ -13,2 +13,3 @@ | ||
- block-expansion | ||
- attribute interpolation | ||
- code is escaped by default for security | ||
@@ -321,2 +322,16 @@ - contextual error reporting at compile & run time | ||
Multiple lines without the comma work fine: | ||
input(type='checkbox' | ||
name='agreement' | ||
checked) | ||
Funky whitespace? fine: | ||
input( | ||
type='checkbox' | ||
name='agreement' | ||
checked) | ||
Colons work: | ||
@@ -326,5 +341,15 @@ | ||
Suppose we have the `user` local `{ id: 12, name: 'tobi' }` | ||
and we wish to create an anchor tag with `href` pointing to "/user/12" | ||
we could use regular javascript concatenation: | ||
a(href='/user/' + user.id)= user.name | ||
or we could use jade's interpolation: | ||
a(href='/user/#{user.id}')= user.name | ||
### 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: | ||
@@ -337,2 +362,15 @@ !!! | ||
or | ||
!!! html | ||
or | ||
doctype html | ||
doctypes are case-insensitive, so the following are equivalent: | ||
doctype Basic | ||
doctype basic | ||
Will output the _html 5_ doctype. Below are the doctypes | ||
@@ -339,0 +377,0 @@ defined by default, which can easily be extended: |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154854
3954
555