jade-js-source 0.19.0 → 0.27.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/jade_js/jade.js +722 -194
 - data/lib/jade_js/runtime.js +64 -8
 - metadata +3 -3
 
    
        data/lib/jade_js/runtime.js
    CHANGED
    
    | 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
      
 2 
     | 
    
         
            +
            jade = (function(exports){
         
     | 
| 
       3 
3 
     | 
    
         
             
            /*!
         
     | 
| 
       4 
4 
     | 
    
         
             
             * Jade - runtime
         
     | 
| 
       5 
5 
     | 
    
         
             
             * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
         
     | 
| 
         @@ -29,41 +29,97 @@ if (!Object.keys) { 
     | 
|
| 
       29 
29 
     | 
    
         
             
                  }
         
     | 
| 
       30 
30 
     | 
    
         
             
                }
         
     | 
| 
       31 
31 
     | 
    
         
             
                return arr;
         
     | 
| 
       32 
     | 
    
         
            -
              } 
     | 
| 
      
 32 
     | 
    
         
            +
              }
         
     | 
| 
      
 33 
     | 
    
         
            +
            }
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            /**
         
     | 
| 
      
 36 
     | 
    
         
            +
             * Merge two attribute objects giving precedence
         
     | 
| 
      
 37 
     | 
    
         
            +
             * to values in object `b`. Classes are special-cased
         
     | 
| 
      
 38 
     | 
    
         
            +
             * allowing for arrays and merging/joining appropriately
         
     | 
| 
      
 39 
     | 
    
         
            +
             * resulting in a string.
         
     | 
| 
      
 40 
     | 
    
         
            +
             *
         
     | 
| 
      
 41 
     | 
    
         
            +
             * @param {Object} a
         
     | 
| 
      
 42 
     | 
    
         
            +
             * @param {Object} b
         
     | 
| 
      
 43 
     | 
    
         
            +
             * @return {Object} a
         
     | 
| 
      
 44 
     | 
    
         
            +
             * @api private
         
     | 
| 
      
 45 
     | 
    
         
            +
             */
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            exports.merge = function merge(a, b) {
         
     | 
| 
      
 48 
     | 
    
         
            +
              var ac = a['class'];
         
     | 
| 
      
 49 
     | 
    
         
            +
              var bc = b['class'];
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              if (ac || bc) {
         
     | 
| 
      
 52 
     | 
    
         
            +
                ac = ac || [];
         
     | 
| 
      
 53 
     | 
    
         
            +
                bc = bc || [];
         
     | 
| 
      
 54 
     | 
    
         
            +
                if (!Array.isArray(ac)) ac = [ac];
         
     | 
| 
      
 55 
     | 
    
         
            +
                if (!Array.isArray(bc)) bc = [bc];
         
     | 
| 
      
 56 
     | 
    
         
            +
                ac = ac.filter(nulls);
         
     | 
| 
      
 57 
     | 
    
         
            +
                bc = bc.filter(nulls);
         
     | 
| 
      
 58 
     | 
    
         
            +
                a['class'] = ac.concat(bc).join(' ');
         
     | 
| 
      
 59 
     | 
    
         
            +
              }
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              for (var key in b) {
         
     | 
| 
      
 62 
     | 
    
         
            +
                if (key != 'class') {
         
     | 
| 
      
 63 
     | 
    
         
            +
                  a[key] = b[key];
         
     | 
| 
      
 64 
     | 
    
         
            +
                }
         
     | 
| 
      
 65 
     | 
    
         
            +
              }
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              return a;
         
     | 
| 
      
 68 
     | 
    
         
            +
            };
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            /**
         
     | 
| 
      
 71 
     | 
    
         
            +
             * Filter null `val`s.
         
     | 
| 
      
 72 
     | 
    
         
            +
             *
         
     | 
| 
      
 73 
     | 
    
         
            +
             * @param {Mixed} val
         
     | 
| 
      
 74 
     | 
    
         
            +
             * @return {Mixed}
         
     | 
| 
      
 75 
     | 
    
         
            +
             * @api private
         
     | 
| 
      
 76 
     | 
    
         
            +
             */
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            function nulls(val) {
         
     | 
| 
      
 79 
     | 
    
         
            +
              return val != null;
         
     | 
| 
       33 
80 
     | 
    
         
             
            }
         
     | 
| 
       34 
81 
     | 
    
         | 
| 
       35 
82 
     | 
    
         
             
            /**
         
     | 
| 
       36 
83 
     | 
    
         
             
             * Render the given attributes object.
         
     | 
| 
       37 
84 
     | 
    
         
             
             *
         
     | 
| 
       38 
85 
     | 
    
         
             
             * @param {Object} obj
         
     | 
| 
      
 86 
     | 
    
         
            +
             * @param {Object} escaped
         
     | 
| 
       39 
87 
     | 
    
         
             
             * @return {String}
         
     | 
| 
       40 
88 
     | 
    
         
             
             * @api private
         
     | 
| 
       41 
89 
     | 
    
         
             
             */
         
     | 
| 
       42 
90 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
            exports.attrs = function attrs(obj){
         
     | 
| 
      
 91 
     | 
    
         
            +
            exports.attrs = function attrs(obj, escaped){
         
     | 
| 
       44 
92 
     | 
    
         
             
              var buf = []
         
     | 
| 
       45 
93 
     | 
    
         
             
                , terse = obj.terse;
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
       46 
95 
     | 
    
         
             
              delete obj.terse;
         
     | 
| 
       47 
96 
     | 
    
         
             
              var keys = Object.keys(obj)
         
     | 
| 
       48 
97 
     | 
    
         
             
                , len = keys.length;
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
       49 
99 
     | 
    
         
             
              if (len) {
         
     | 
| 
       50 
100 
     | 
    
         
             
                buf.push('');
         
     | 
| 
       51 
101 
     | 
    
         
             
                for (var i = 0; i < len; ++i) {
         
     | 
| 
       52 
102 
     | 
    
         
             
                  var key = keys[i]
         
     | 
| 
       53 
103 
     | 
    
         
             
                    , val = obj[key];
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
       54 
105 
     | 
    
         
             
                  if ('boolean' == typeof val || null == val) {
         
     | 
| 
       55 
106 
     | 
    
         
             
                    if (val) {
         
     | 
| 
       56 
107 
     | 
    
         
             
                      terse
         
     | 
| 
       57 
108 
     | 
    
         
             
                        ? buf.push(key)
         
     | 
| 
       58 
109 
     | 
    
         
             
                        : buf.push(key + '="' + key + '"');
         
     | 
| 
       59 
110 
     | 
    
         
             
                    }
         
     | 
| 
      
 111 
     | 
    
         
            +
                  } else if (0 == key.indexOf('data') && 'string' != typeof val) {
         
     | 
| 
      
 112 
     | 
    
         
            +
                    buf.push(key + "='" + JSON.stringify(val) + "'");
         
     | 
| 
       60 
113 
     | 
    
         
             
                  } else if ('class' == key && Array.isArray(val)) {
         
     | 
| 
       61 
114 
     | 
    
         
             
                    buf.push(key + '="' + exports.escape(val.join(' ')) + '"');
         
     | 
| 
       62 
     | 
    
         
            -
                  } else {
         
     | 
| 
      
 115 
     | 
    
         
            +
                  } else if (escaped && escaped[key]) {
         
     | 
| 
       63 
116 
     | 
    
         
             
                    buf.push(key + '="' + exports.escape(val) + '"');
         
     | 
| 
      
 117 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 118 
     | 
    
         
            +
                    buf.push(key + '="' + val + '"');
         
     | 
| 
       64 
119 
     | 
    
         
             
                  }
         
     | 
| 
       65 
120 
     | 
    
         
             
                }
         
     | 
| 
       66 
121 
     | 
    
         
             
              }
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
       67 
123 
     | 
    
         
             
              return buf.join(' ');
         
     | 
| 
       68 
124 
     | 
    
         
             
            };
         
     | 
| 
       69 
125 
     | 
    
         | 
| 
         @@ -77,7 +133,7 @@ exports.attrs = function attrs(obj){ 
     | 
|
| 
       77 
133 
     | 
    
         | 
| 
       78 
134 
     | 
    
         
             
            exports.escape = function escape(html){
         
     | 
| 
       79 
135 
     | 
    
         
             
              return String(html)
         
     | 
| 
       80 
     | 
    
         
            -
                .replace(/&( 
     | 
| 
      
 136 
     | 
    
         
            +
                .replace(/&(?!(\w+|\#\d+);)/g, '&')
         
     | 
| 
       81 
137 
     | 
    
         
             
                .replace(/</g, '<')
         
     | 
| 
       82 
138 
     | 
    
         
             
                .replace(/>/g, '>')
         
     | 
| 
       83 
139 
     | 
    
         
             
                .replace(/"/g, '"');
         
     | 
| 
         @@ -100,7 +156,7 @@ exports.rethrow = function rethrow(err, filename, lineno){ 
     | 
|
| 
       100 
156 
     | 
    
         
             
                , str = require('fs').readFileSync(filename, 'utf8')
         
     | 
| 
       101 
157 
     | 
    
         
             
                , lines = str.split('\n')
         
     | 
| 
       102 
158 
     | 
    
         
             
                , start = Math.max(lineno - context, 0)
         
     | 
| 
       103 
     | 
    
         
            -
                , end = Math.min(lines.length, lineno + context); 
     | 
| 
      
 159 
     | 
    
         
            +
                , end = Math.min(lines.length, lineno + context);
         
     | 
| 
       104 
160 
     | 
    
         | 
| 
       105 
161 
     | 
    
         
             
              // Error context
         
     | 
| 
       106 
162 
     | 
    
         
             
              var context = lines.slice(start, end).map(function(line, i){
         
     | 
| 
         @@ -113,11 +169,11 @@ exports.rethrow = function rethrow(err, filename, lineno){ 
     | 
|
| 
       113 
169 
     | 
    
         | 
| 
       114 
170 
     | 
    
         
             
              // Alter exception message
         
     | 
| 
       115 
171 
     | 
    
         
             
              err.path = filename;
         
     | 
| 
       116 
     | 
    
         
            -
              err.message = (filename || 'Jade') + ':' + lineno 
     | 
| 
      
 172 
     | 
    
         
            +
              err.message = (filename || 'Jade') + ':' + lineno
         
     | 
| 
       117 
173 
     | 
    
         
             
                + '\n' + context + '\n\n' + err.message;
         
     | 
| 
       118 
174 
     | 
    
         
             
              throw err;
         
     | 
| 
       119 
175 
     | 
    
         
             
            };
         
     | 
| 
       120 
176 
     | 
    
         | 
| 
       121 
177 
     | 
    
         
             
              return exports;
         
     | 
| 
       122 
178 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
            })({});
         
     | 
| 
      
 179 
     | 
    
         
            +
            })({});
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: jade-js-source
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.27.6
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2012-10-26 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       15 
15 
     | 
    
         
             
            description: ! "      Jade is a high performance template engine heavily influenced
         
     | 
| 
       16 
16 
     | 
    
         
             
              by Haml \n      and implemented with JavaScript for node.\n"
         
     | 
| 
         @@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       42 
42 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       43 
43 
     | 
    
         
             
            requirements: []
         
     | 
| 
       44 
44 
     | 
    
         
             
            rubyforge_project: jade-js-source
         
     | 
| 
       45 
     | 
    
         
            -
            rubygems_version: 1.8. 
     | 
| 
      
 45 
     | 
    
         
            +
            rubygems_version: 1.8.17
         
     | 
| 
       46 
46 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       47 
47 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       48 
48 
     | 
    
         
             
            summary: Jade - template engine
         
     |