pug-ruby 1.0.2 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.rubocop.yml +81 -0
  4. data/.travis.yml +17 -8
  5. data/.yardopts +4 -0
  6. data/Gemfile +3 -3
  7. data/Gemfile.lock +32 -0
  8. data/LICENSE +21 -0
  9. data/README.md +256 -24
  10. data/Rakefile +74 -8
  11. data/lib/jade-pug/base.rb +178 -0
  12. data/lib/jade-pug/compiler.rb +166 -0
  13. data/lib/jade-pug/config.rb +60 -0
  14. data/lib/jade-pug/errors/compilation-error.rb +14 -0
  15. data/lib/jade-pug/errors/compiler-error.rb +13 -0
  16. data/lib/jade-pug/shipped-compiler.rb +80 -0
  17. data/lib/jade-pug/system-compiler.rb +139 -0
  18. data/lib/jade-ruby/compilation-essentials.rb +24 -0
  19. data/lib/jade-ruby/config.rb +17 -44
  20. data/lib/jade-ruby/errors/compilation-error.rb +14 -0
  21. data/lib/jade-ruby/errors/compiler-error.rb +13 -0
  22. data/lib/jade-ruby/shipped-compiler.rb +15 -0
  23. data/lib/jade-ruby/system-compiler.rb +15 -0
  24. data/lib/pug-ruby.rb +46 -5
  25. data/lib/pug-ruby/compilation-essentials.rb +29 -0
  26. data/lib/pug-ruby/config.rb +11 -37
  27. data/lib/pug-ruby/errors/compilation-error.rb +14 -0
  28. data/lib/pug-ruby/errors/compiler-error.rb +13 -0
  29. data/lib/pug-ruby/shipped-compiler.rb +15 -0
  30. data/lib/pug-ruby/system-compiler.rb +15 -0
  31. data/lib/pug-ruby/version.rb +7 -0
  32. data/package.json +11 -0
  33. data/pug-ruby.gemspec +19 -12
  34. data/support/browserify-jade-runtime.js +19 -0
  35. data/support/browserify-jade.js +17 -0
  36. data/support/browserify-pug-runtime.js +19 -0
  37. data/support/browserify-pug.js +23 -0
  38. data/support/minify-jade.js +11 -0
  39. data/support/minify-pug.js +11 -0
  40. data/test/helper.rb +202 -0
  41. data/test/jade/includes/includes/footer.jade +1 -1
  42. data/test/manual.html +21 -0
  43. data/test/manual.rb +25 -0
  44. data/test/pug/includes/includes/footer.pug +1 -1
  45. data/test/pug/index.pug +3 -3
  46. data/test/test-jade.rb +3 -67
  47. data/test/test-pug.rb +3 -67
  48. data/vendor/jade-1.0.0.min.js +1 -0
  49. data/vendor/jade-1.0.1.min.js +1 -0
  50. data/vendor/jade-1.0.2.min.js +1 -0
  51. data/vendor/jade-1.1.0.min.js +1 -0
  52. data/vendor/jade-1.1.1.min.js +1 -0
  53. data/vendor/jade-1.1.2.min.js +1 -0
  54. data/vendor/jade-1.1.3.min.js +1 -0
  55. data/vendor/jade-1.1.4.min.js +1 -0
  56. data/vendor/jade-1.1.5.min.js +1 -0
  57. data/vendor/jade-1.10.0.min.js +1 -0
  58. data/vendor/jade-1.11.0.min.js +1 -0
  59. data/vendor/jade-1.2.0.min.js +1 -0
  60. data/vendor/jade-1.3.0.min.js +1 -0
  61. data/vendor/jade-1.3.1.min.js +1 -0
  62. data/vendor/jade-1.4.0.min.js +1 -0
  63. data/vendor/jade-1.4.1.min.js +1 -0
  64. data/vendor/jade-1.4.2.min.js +1 -0
  65. data/vendor/jade-1.5.0.min.js +1 -0
  66. data/vendor/jade-1.6.0.min.js +1 -0
  67. data/vendor/jade-1.7.0.min.js +1 -0
  68. data/vendor/jade-1.8.0.min.js +1 -0
  69. data/vendor/jade-1.8.1.min.js +1 -0
  70. data/vendor/jade-1.8.2.min.js +1 -0
  71. data/vendor/jade-1.9.0.min.js +1 -0
  72. data/vendor/jade-1.9.1.min.js +1 -0
  73. data/vendor/jade-1.9.2.min.js +1 -0
  74. data/vendor/jade-runtime-1.0.0-license +22 -0
  75. data/vendor/jade-runtime-1.0.0.js +199 -0
  76. data/vendor/jade-runtime-1.0.1-license +22 -0
  77. data/vendor/jade-runtime-1.0.1.js +199 -0
  78. data/vendor/jade-runtime-1.0.2-license +22 -0
  79. data/vendor/jade-runtime-1.0.2.js +199 -0
  80. data/vendor/jade-runtime-1.1.0-license +22 -0
  81. data/vendor/jade-runtime-1.1.0.js +199 -0
  82. data/vendor/jade-runtime-1.1.1-license +22 -0
  83. data/vendor/jade-runtime-1.1.1.js +199 -0
  84. data/vendor/jade-runtime-1.1.2-license +22 -0
  85. data/vendor/jade-runtime-1.1.2.js +200 -0
  86. data/vendor/jade-runtime-1.1.3-license +22 -0
  87. data/vendor/jade-runtime-1.1.3.js +200 -0
  88. data/vendor/jade-runtime-1.1.4-license +22 -0
  89. data/vendor/jade-runtime-1.1.4.js +200 -0
  90. data/vendor/jade-runtime-1.1.5-license +22 -0
  91. data/vendor/jade-runtime-1.1.5.js +200 -0
  92. data/vendor/jade-runtime-1.10.0-license +22 -0
  93. data/vendor/jade-runtime-1.10.0.js +233 -0
  94. data/vendor/jade-runtime-1.11.0-license +22 -0
  95. data/vendor/jade-runtime-1.11.0.js +246 -0
  96. data/vendor/jade-runtime-1.2.0-license +22 -0
  97. data/vendor/jade-runtime-1.2.0.js +200 -0
  98. data/vendor/jade-runtime-1.3.0-license +22 -0
  99. data/vendor/jade-runtime-1.3.0.js +200 -0
  100. data/vendor/jade-runtime-1.3.1-license +22 -0
  101. data/vendor/jade-runtime-1.3.1.js +200 -0
  102. data/vendor/jade-runtime-1.4.0-license +22 -0
  103. data/vendor/jade-runtime-1.4.0.js +200 -0
  104. data/vendor/jade-runtime-1.4.1-license +22 -0
  105. data/vendor/jade-runtime-1.4.1.js +200 -0
  106. data/vendor/jade-runtime-1.4.2-license +22 -0
  107. data/vendor/jade-runtime-1.4.2.js +200 -0
  108. data/vendor/jade-runtime-1.5.0-license +22 -0
  109. data/vendor/jade-runtime-1.5.0.js +200 -0
  110. data/vendor/jade-runtime-1.6.0-license +22 -0
  111. data/vendor/jade-runtime-1.6.0.js +200 -0
  112. data/vendor/jade-runtime-1.7.0-license +22 -0
  113. data/vendor/jade-runtime-1.7.0.js +200 -0
  114. data/vendor/jade-runtime-1.8.0-license +22 -0
  115. data/vendor/jade-runtime-1.8.0.js +228 -0
  116. data/vendor/jade-runtime-1.8.1-license +22 -0
  117. data/vendor/jade-runtime-1.8.1.js +228 -0
  118. data/vendor/jade-runtime-1.8.2-license +22 -0
  119. data/vendor/jade-runtime-1.8.2.js +228 -0
  120. data/vendor/jade-runtime-1.9.0-license +22 -0
  121. data/vendor/jade-runtime-1.9.0.js +228 -0
  122. data/vendor/jade-runtime-1.9.1-license +22 -0
  123. data/vendor/jade-runtime-1.9.1.js +228 -0
  124. data/vendor/jade-runtime-1.9.2-license +22 -0
  125. data/vendor/jade-runtime-1.9.2.js +228 -0
  126. data/vendor/pug-2.0.0-beta.12-license +22 -0
  127. data/vendor/pug-2.0.0-beta.12.min.js +1 -0
  128. data/vendor/pug-2.0.0-beta1-license +22 -0
  129. data/vendor/pug-2.0.0-beta1.min.js +1 -0
  130. data/vendor/pug-2.0.0-beta10-license +22 -0
  131. data/vendor/pug-2.0.0-beta10.min.js +1 -0
  132. data/vendor/pug-2.0.0-beta11-license +22 -0
  133. data/vendor/pug-2.0.0-beta11.min.js +1 -0
  134. data/vendor/pug-2.0.0-beta2-license +22 -0
  135. data/vendor/pug-2.0.0-beta2.min.js +1 -0
  136. data/vendor/pug-2.0.0-beta3-license +22 -0
  137. data/vendor/pug-2.0.0-beta3.min.js +1 -0
  138. data/vendor/pug-2.0.0-beta4-license +22 -0
  139. data/vendor/pug-2.0.0-beta4.min.js +1 -0
  140. data/vendor/pug-2.0.0-beta5-license +22 -0
  141. data/vendor/pug-2.0.0-beta5.min.js +1 -0
  142. data/vendor/pug-2.0.0-beta6-license +22 -0
  143. data/vendor/pug-2.0.0-beta6.min.js +1 -0
  144. data/vendor/pug-2.0.0-beta7-license +22 -0
  145. data/vendor/pug-2.0.0-beta7.min.js +1 -0
  146. data/vendor/pug-2.0.0-beta8-license +22 -0
  147. data/vendor/pug-2.0.0-beta8.min.js +1 -0
  148. data/vendor/pug-2.0.0-beta9-license +22 -0
  149. data/vendor/pug-2.0.0-beta9.min.js +1 -0
  150. data/vendor/pug-2.0.0-rc.1-license +22 -0
  151. data/vendor/pug-2.0.0-rc.1.min.js +1 -0
  152. data/vendor/pug-2.0.0-rc.2-license +22 -0
  153. data/vendor/pug-2.0.0-rc.2.min.js +1 -0
  154. data/vendor/pug-2.0.0-rc.3-license +22 -0
  155. data/vendor/pug-2.0.0-rc.3.min.js +1 -0
  156. data/vendor/pug-runtime-2.0.0-license +19 -0
  157. data/vendor/pug-runtime-2.0.0.js +266 -0
  158. data/vendor/pug-runtime-2.0.1-license +19 -0
  159. data/vendor/pug-runtime-2.0.1.js +266 -0
  160. data/vendor/pug-runtime-2.0.2-license +19 -0
  161. data/vendor/pug-runtime-2.0.2.js +267 -0
  162. metadata +242 -13
  163. data/lib/jade-ruby/compile.rb +0 -79
  164. data/lib/pug-ruby/compile.rb +0 -88
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009-2010 TJ Holowaychuk <tj@vision-media.ca>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,200 @@
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jade = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+
3
+ },{}],2:[function(require,module,exports){
4
+ 'use strict';
5
+
6
+ /**
7
+ * Merge two attribute objects giving precedence
8
+ * to values in object `b`. Classes are special-cased
9
+ * allowing for arrays and merging/joining appropriately
10
+ * resulting in a string.
11
+ *
12
+ * @param {Object} a
13
+ * @param {Object} b
14
+ * @return {Object} a
15
+ * @api private
16
+ */
17
+
18
+ exports.merge = function merge(a, b) {
19
+ if (arguments.length === 1) {
20
+ var attrs = a[0];
21
+ for (var i = 1; i < a.length; i++) {
22
+ attrs = merge(attrs, a[i]);
23
+ }
24
+ return attrs;
25
+ }
26
+ var ac = a['class'];
27
+ var bc = b['class'];
28
+
29
+ if (ac || bc) {
30
+ ac = ac || [];
31
+ bc = bc || [];
32
+ if (!Array.isArray(ac)) ac = [ac];
33
+ if (!Array.isArray(bc)) bc = [bc];
34
+ a['class'] = ac.concat(bc).filter(nulls);
35
+ }
36
+
37
+ for (var key in b) {
38
+ if (key != 'class') {
39
+ a[key] = b[key];
40
+ }
41
+ }
42
+
43
+ return a;
44
+ };
45
+
46
+ /**
47
+ * Filter null `val`s.
48
+ *
49
+ * @param {*} val
50
+ * @return {Boolean}
51
+ * @api private
52
+ */
53
+
54
+ function nulls(val) {
55
+ return val != null && val !== '';
56
+ }
57
+
58
+ /**
59
+ * join array as classes.
60
+ *
61
+ * @param {*} val
62
+ * @return {String}
63
+ */
64
+ exports.joinClasses = joinClasses;
65
+ function joinClasses(val) {
66
+ return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
67
+ }
68
+
69
+ /**
70
+ * Render the given classes.
71
+ *
72
+ * @param {Array} classes
73
+ * @param {Array.<Boolean>} escaped
74
+ * @return {String}
75
+ */
76
+ exports.cls = function cls(classes, escaped) {
77
+ var buf = [];
78
+ for (var i = 0; i < classes.length; i++) {
79
+ if (escaped && escaped[i]) {
80
+ buf.push(exports.escape(joinClasses([classes[i]])));
81
+ } else {
82
+ buf.push(joinClasses(classes[i]));
83
+ }
84
+ }
85
+ var text = joinClasses(buf);
86
+ if (text.length) {
87
+ return ' class="' + text + '"';
88
+ } else {
89
+ return '';
90
+ }
91
+ };
92
+
93
+ /**
94
+ * Render the given attribute.
95
+ *
96
+ * @param {String} key
97
+ * @param {String} val
98
+ * @param {Boolean} escaped
99
+ * @param {Boolean} terse
100
+ * @return {String}
101
+ */
102
+ exports.attr = function attr(key, val, escaped, terse) {
103
+ if ('boolean' == typeof val || null == val) {
104
+ if (val) {
105
+ return ' ' + (terse ? key : key + '="' + key + '"');
106
+ } else {
107
+ return '';
108
+ }
109
+ } else if (0 == key.indexOf('data') && 'string' != typeof val) {
110
+ return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, '&apos;') + "'";
111
+ } else if (escaped) {
112
+ return ' ' + key + '="' + exports.escape(val) + '"';
113
+ } else {
114
+ return ' ' + key + '="' + val + '"';
115
+ }
116
+ };
117
+
118
+ /**
119
+ * Render the given attributes object.
120
+ *
121
+ * @param {Object} obj
122
+ * @param {Object} escaped
123
+ * @return {String}
124
+ */
125
+ exports.attrs = function attrs(obj, terse) {
126
+ var buf = [];
127
+
128
+ var keys = Object.keys(obj);
129
+
130
+ if (keys.length) {
131
+ for (var i = 0; i < keys.length; ++i) {
132
+ var key = keys[i],
133
+ val = obj[key];
134
+
135
+ if ('class' == key) {
136
+ if (val = joinClasses(val)) {
137
+ buf.push(' ' + key + '="' + val + '"');
138
+ }
139
+ } else {
140
+ buf.push(exports.attr(key, val, false, terse));
141
+ }
142
+ }
143
+ }
144
+
145
+ return buf.join('');
146
+ };
147
+
148
+ /**
149
+ * Escape the given string of `html`.
150
+ *
151
+ * @param {String} html
152
+ * @return {String}
153
+ * @api private
154
+ */
155
+
156
+ exports.escape = function escape(html) {
157
+ var result = String(html).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
158
+ if (result === '' + html) return html;else return result;
159
+ };
160
+
161
+ /**
162
+ * Re-throw the given `err` in context to the
163
+ * the jade in `filename` at the given `lineno`.
164
+ *
165
+ * @param {Error} err
166
+ * @param {String} filename
167
+ * @param {String} lineno
168
+ * @api private
169
+ */
170
+
171
+ exports.rethrow = function rethrow(err, filename, lineno, str) {
172
+ if (!(err instanceof Error)) throw err;
173
+ if ((typeof window != 'undefined' || !filename) && !str) {
174
+ err.message += ' on line ' + lineno;
175
+ throw err;
176
+ }
177
+ try {
178
+ str = str || require('fs').readFileSync(filename, 'utf8');
179
+ } catch (ex) {
180
+ rethrow(err, null, lineno);
181
+ }
182
+ var context = 3,
183
+ lines = str.split('\n'),
184
+ start = Math.max(lineno - context, 0),
185
+ end = Math.min(lines.length, lineno + context);
186
+
187
+ // Error context
188
+ var context = lines.slice(start, end).map(function (line, i) {
189
+ var curr = i + start + 1;
190
+ return (curr == lineno ? ' > ' : ' ') + curr + '| ' + line;
191
+ }).join('\n');
192
+
193
+ // Alter exception message
194
+ err.path = filename;
195
+ err.message = (filename || 'Jade') + ':' + lineno + '\n' + context + '\n\n' + err.message;
196
+ throw err;
197
+ };
198
+
199
+ },{"fs":1}]},{},[2])(2)
200
+ });
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,200 @@
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jade = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+
3
+ },{}],2:[function(require,module,exports){
4
+ 'use strict';
5
+
6
+ /**
7
+ * Merge two attribute objects giving precedence
8
+ * to values in object `b`. Classes are special-cased
9
+ * allowing for arrays and merging/joining appropriately
10
+ * resulting in a string.
11
+ *
12
+ * @param {Object} a
13
+ * @param {Object} b
14
+ * @return {Object} a
15
+ * @api private
16
+ */
17
+
18
+ exports.merge = function merge(a, b) {
19
+ if (arguments.length === 1) {
20
+ var attrs = a[0];
21
+ for (var i = 1; i < a.length; i++) {
22
+ attrs = merge(attrs, a[i]);
23
+ }
24
+ return attrs;
25
+ }
26
+ var ac = a['class'];
27
+ var bc = b['class'];
28
+
29
+ if (ac || bc) {
30
+ ac = ac || [];
31
+ bc = bc || [];
32
+ if (!Array.isArray(ac)) ac = [ac];
33
+ if (!Array.isArray(bc)) bc = [bc];
34
+ a['class'] = ac.concat(bc).filter(nulls);
35
+ }
36
+
37
+ for (var key in b) {
38
+ if (key != 'class') {
39
+ a[key] = b[key];
40
+ }
41
+ }
42
+
43
+ return a;
44
+ };
45
+
46
+ /**
47
+ * Filter null `val`s.
48
+ *
49
+ * @param {*} val
50
+ * @return {Boolean}
51
+ * @api private
52
+ */
53
+
54
+ function nulls(val) {
55
+ return val != null && val !== '';
56
+ }
57
+
58
+ /**
59
+ * join array as classes.
60
+ *
61
+ * @param {*} val
62
+ * @return {String}
63
+ */
64
+ exports.joinClasses = joinClasses;
65
+ function joinClasses(val) {
66
+ return Array.isArray(val) ? val.map(joinClasses).filter(nulls).join(' ') : val;
67
+ }
68
+
69
+ /**
70
+ * Render the given classes.
71
+ *
72
+ * @param {Array} classes
73
+ * @param {Array.<Boolean>} escaped
74
+ * @return {String}
75
+ */
76
+ exports.cls = function cls(classes, escaped) {
77
+ var buf = [];
78
+ for (var i = 0; i < classes.length; i++) {
79
+ if (escaped && escaped[i]) {
80
+ buf.push(exports.escape(joinClasses([classes[i]])));
81
+ } else {
82
+ buf.push(joinClasses(classes[i]));
83
+ }
84
+ }
85
+ var text = joinClasses(buf);
86
+ if (text.length) {
87
+ return ' class="' + text + '"';
88
+ } else {
89
+ return '';
90
+ }
91
+ };
92
+
93
+ /**
94
+ * Render the given attribute.
95
+ *
96
+ * @param {String} key
97
+ * @param {String} val
98
+ * @param {Boolean} escaped
99
+ * @param {Boolean} terse
100
+ * @return {String}
101
+ */
102
+ exports.attr = function attr(key, val, escaped, terse) {
103
+ if ('boolean' == typeof val || null == val) {
104
+ if (val) {
105
+ return ' ' + (terse ? key : key + '="' + key + '"');
106
+ } else {
107
+ return '';
108
+ }
109
+ } else if (0 == key.indexOf('data') && 'string' != typeof val) {
110
+ return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, '&apos;') + "'";
111
+ } else if (escaped) {
112
+ return ' ' + key + '="' + exports.escape(val) + '"';
113
+ } else {
114
+ return ' ' + key + '="' + val + '"';
115
+ }
116
+ };
117
+
118
+ /**
119
+ * Render the given attributes object.
120
+ *
121
+ * @param {Object} obj
122
+ * @param {Object} escaped
123
+ * @return {String}
124
+ */
125
+ exports.attrs = function attrs(obj, terse) {
126
+ var buf = [];
127
+
128
+ var keys = Object.keys(obj);
129
+
130
+ if (keys.length) {
131
+ for (var i = 0; i < keys.length; ++i) {
132
+ var key = keys[i],
133
+ val = obj[key];
134
+
135
+ if ('class' == key) {
136
+ if (val = joinClasses(val)) {
137
+ buf.push(' ' + key + '="' + val + '"');
138
+ }
139
+ } else {
140
+ buf.push(exports.attr(key, val, false, terse));
141
+ }
142
+ }
143
+ }
144
+
145
+ return buf.join('');
146
+ };
147
+
148
+ /**
149
+ * Escape the given string of `html`.
150
+ *
151
+ * @param {String} html
152
+ * @return {String}
153
+ * @api private
154
+ */
155
+
156
+ exports.escape = function escape(html) {
157
+ var result = String(html).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
158
+ if (result === '' + html) return html;else return result;
159
+ };
160
+
161
+ /**
162
+ * Re-throw the given `err` in context to the
163
+ * the jade in `filename` at the given `lineno`.
164
+ *
165
+ * @param {Error} err
166
+ * @param {String} filename
167
+ * @param {String} lineno
168
+ * @api private
169
+ */
170
+
171
+ exports.rethrow = function rethrow(err, filename, lineno, str) {
172
+ if (!(err instanceof Error)) throw err;
173
+ if ((typeof window != 'undefined' || !filename) && !str) {
174
+ err.message += ' on line ' + lineno;
175
+ throw err;
176
+ }
177
+ try {
178
+ str = str || require('fs').readFileSync(filename, 'utf8');
179
+ } catch (ex) {
180
+ rethrow(err, null, lineno);
181
+ }
182
+ var context = 3,
183
+ lines = str.split('\n'),
184
+ start = Math.max(lineno - context, 0),
185
+ end = Math.min(lines.length, lineno + context);
186
+
187
+ // Error context
188
+ var context = lines.slice(start, end).map(function (line, i) {
189
+ var curr = i + start + 1;
190
+ return (curr == lineno ? ' > ' : ' ') + curr + '| ' + line;
191
+ }).join('\n');
192
+
193
+ // Alter exception message
194
+ err.path = filename;
195
+ err.message = (filename || 'Jade') + ':' + lineno + '\n' + context + '\n\n' + err.message;
196
+ throw err;
197
+ };
198
+
199
+ },{"fs":1}]},{},[2])(2)
200
+ });
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.