Permalink
Browse files

rebuild

  • Loading branch information...
1 parent 48cc48a commit dff55a57cf1b180d667ad60225a3ec4e36e0ad67 @tj tj committed Aug 26, 2011
Showing with 51 additions and 4 deletions.
  1. +37 −2 jade.js
  2. +1 −1 jade.min.js
  3. +12 −0 runtime.js
  4. +1 −1 runtime.min.js
View
@@ -1189,12 +1189,34 @@ Lexer.prototype = {
},
/**
+ * Conditional.
+ */
+
+ conditional: function() {
+ var captures;
+ if (captures = /^(if|unless|else if|else) *([^\n]*)/.exec(this.input)) {
+ this.consume(captures[0].length);
+ var type = captures[1]
+ , js = captures[2];
+
+ switch (type) {
+ case 'if': js = 'if (' + js + ')'; break;
+ case 'unless': js = 'if (!(' + js + '))'; break;
+ case 'else if': js = 'else if (' + js + ')'; break;
+ case 'else': js = 'else'; break;
+ }
+
+ return this.tok('code', js);
+ }
+ },
+
+ /**
* Each.
*/
each: function() {
var captures;
- if (captures = /^- *each *(\w+)(?: *, *(\w+))? * in *([^\n]+)/.exec(this.input)) {
+ if (captures = /^(?:- *)?(?:each|for) *(\w+)(?: *, *(\w+))? * in *([^\n]+)/.exec(this.input)) {
this.consume(captures[0].length);
var tok = this.tok('each', captures[1]);
tok.key = captures[2] || 'index';
@@ -1469,9 +1491,10 @@ Lexer.prototype = {
|| this.doctype()
|| this.include()
|| this.mixin()
+ || this.conditional()
+ || this.each()
|| this.tag()
|| this.filter()
- || this.each()
|| this.code()
|| this.id()
|| this.className()
@@ -2539,6 +2562,18 @@ require.register("runtime.js", function(module, exports, require){
* MIT Licensed
*/
+if (!Object.keys) {
+ Object.keys = function(obj){
+ var arr = [];
+ for (var key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ arr.push(obj);
+ }
+ }
+ return arr;
+ }
+}
+
/**
* Render the given attributes object.
*
Oops, something went wrong.

0 comments on commit dff55a5

Please sign in to comment.