pug-ruby 1.0.2 → 2.0.0.rc1
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.rubocop.yml +81 -0
- data/.travis.yml +17 -8
- data/.yardopts +4 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +32 -0
- data/LICENSE +21 -0
- data/README.md +256 -24
- data/Rakefile +74 -8
- data/lib/jade-pug/base.rb +178 -0
- data/lib/jade-pug/compiler.rb +166 -0
- data/lib/jade-pug/config.rb +60 -0
- data/lib/jade-pug/errors/compilation-error.rb +14 -0
- data/lib/jade-pug/errors/compiler-error.rb +13 -0
- data/lib/jade-pug/shipped-compiler.rb +80 -0
- data/lib/jade-pug/system-compiler.rb +139 -0
- data/lib/jade-ruby/compilation-essentials.rb +24 -0
- data/lib/jade-ruby/config.rb +17 -44
- data/lib/jade-ruby/errors/compilation-error.rb +14 -0
- data/lib/jade-ruby/errors/compiler-error.rb +13 -0
- data/lib/jade-ruby/shipped-compiler.rb +15 -0
- data/lib/jade-ruby/system-compiler.rb +15 -0
- data/lib/pug-ruby.rb +46 -5
- data/lib/pug-ruby/compilation-essentials.rb +29 -0
- data/lib/pug-ruby/config.rb +11 -37
- data/lib/pug-ruby/errors/compilation-error.rb +14 -0
- data/lib/pug-ruby/errors/compiler-error.rb +13 -0
- data/lib/pug-ruby/shipped-compiler.rb +15 -0
- data/lib/pug-ruby/system-compiler.rb +15 -0
- data/lib/pug-ruby/version.rb +7 -0
- data/package.json +11 -0
- data/pug-ruby.gemspec +19 -12
- data/support/browserify-jade-runtime.js +19 -0
- data/support/browserify-jade.js +17 -0
- data/support/browserify-pug-runtime.js +19 -0
- data/support/browserify-pug.js +23 -0
- data/support/minify-jade.js +11 -0
- data/support/minify-pug.js +11 -0
- data/test/helper.rb +202 -0
- data/test/jade/includes/includes/footer.jade +1 -1
- data/test/manual.html +21 -0
- data/test/manual.rb +25 -0
- data/test/pug/includes/includes/footer.pug +1 -1
- data/test/pug/index.pug +3 -3
- data/test/test-jade.rb +3 -67
- data/test/test-pug.rb +3 -67
- data/vendor/jade-1.0.0.min.js +1 -0
- data/vendor/jade-1.0.1.min.js +1 -0
- data/vendor/jade-1.0.2.min.js +1 -0
- data/vendor/jade-1.1.0.min.js +1 -0
- data/vendor/jade-1.1.1.min.js +1 -0
- data/vendor/jade-1.1.2.min.js +1 -0
- data/vendor/jade-1.1.3.min.js +1 -0
- data/vendor/jade-1.1.4.min.js +1 -0
- data/vendor/jade-1.1.5.min.js +1 -0
- data/vendor/jade-1.10.0.min.js +1 -0
- data/vendor/jade-1.11.0.min.js +1 -0
- data/vendor/jade-1.2.0.min.js +1 -0
- data/vendor/jade-1.3.0.min.js +1 -0
- data/vendor/jade-1.3.1.min.js +1 -0
- data/vendor/jade-1.4.0.min.js +1 -0
- data/vendor/jade-1.4.1.min.js +1 -0
- data/vendor/jade-1.4.2.min.js +1 -0
- data/vendor/jade-1.5.0.min.js +1 -0
- data/vendor/jade-1.6.0.min.js +1 -0
- data/vendor/jade-1.7.0.min.js +1 -0
- data/vendor/jade-1.8.0.min.js +1 -0
- data/vendor/jade-1.8.1.min.js +1 -0
- data/vendor/jade-1.8.2.min.js +1 -0
- data/vendor/jade-1.9.0.min.js +1 -0
- data/vendor/jade-1.9.1.min.js +1 -0
- data/vendor/jade-1.9.2.min.js +1 -0
- data/vendor/jade-runtime-1.0.0-license +22 -0
- data/vendor/jade-runtime-1.0.0.js +199 -0
- data/vendor/jade-runtime-1.0.1-license +22 -0
- data/vendor/jade-runtime-1.0.1.js +199 -0
- data/vendor/jade-runtime-1.0.2-license +22 -0
- data/vendor/jade-runtime-1.0.2.js +199 -0
- data/vendor/jade-runtime-1.1.0-license +22 -0
- data/vendor/jade-runtime-1.1.0.js +199 -0
- data/vendor/jade-runtime-1.1.1-license +22 -0
- data/vendor/jade-runtime-1.1.1.js +199 -0
- data/vendor/jade-runtime-1.1.2-license +22 -0
- data/vendor/jade-runtime-1.1.2.js +200 -0
- data/vendor/jade-runtime-1.1.3-license +22 -0
- data/vendor/jade-runtime-1.1.3.js +200 -0
- data/vendor/jade-runtime-1.1.4-license +22 -0
- data/vendor/jade-runtime-1.1.4.js +200 -0
- data/vendor/jade-runtime-1.1.5-license +22 -0
- data/vendor/jade-runtime-1.1.5.js +200 -0
- data/vendor/jade-runtime-1.10.0-license +22 -0
- data/vendor/jade-runtime-1.10.0.js +233 -0
- data/vendor/jade-runtime-1.11.0-license +22 -0
- data/vendor/jade-runtime-1.11.0.js +246 -0
- data/vendor/jade-runtime-1.2.0-license +22 -0
- data/vendor/jade-runtime-1.2.0.js +200 -0
- data/vendor/jade-runtime-1.3.0-license +22 -0
- data/vendor/jade-runtime-1.3.0.js +200 -0
- data/vendor/jade-runtime-1.3.1-license +22 -0
- data/vendor/jade-runtime-1.3.1.js +200 -0
- data/vendor/jade-runtime-1.4.0-license +22 -0
- data/vendor/jade-runtime-1.4.0.js +200 -0
- data/vendor/jade-runtime-1.4.1-license +22 -0
- data/vendor/jade-runtime-1.4.1.js +200 -0
- data/vendor/jade-runtime-1.4.2-license +22 -0
- data/vendor/jade-runtime-1.4.2.js +200 -0
- data/vendor/jade-runtime-1.5.0-license +22 -0
- data/vendor/jade-runtime-1.5.0.js +200 -0
- data/vendor/jade-runtime-1.6.0-license +22 -0
- data/vendor/jade-runtime-1.6.0.js +200 -0
- data/vendor/jade-runtime-1.7.0-license +22 -0
- data/vendor/jade-runtime-1.7.0.js +200 -0
- data/vendor/jade-runtime-1.8.0-license +22 -0
- data/vendor/jade-runtime-1.8.0.js +228 -0
- data/vendor/jade-runtime-1.8.1-license +22 -0
- data/vendor/jade-runtime-1.8.1.js +228 -0
- data/vendor/jade-runtime-1.8.2-license +22 -0
- data/vendor/jade-runtime-1.8.2.js +228 -0
- data/vendor/jade-runtime-1.9.0-license +22 -0
- data/vendor/jade-runtime-1.9.0.js +228 -0
- data/vendor/jade-runtime-1.9.1-license +22 -0
- data/vendor/jade-runtime-1.9.1.js +228 -0
- data/vendor/jade-runtime-1.9.2-license +22 -0
- data/vendor/jade-runtime-1.9.2.js +228 -0
- data/vendor/pug-2.0.0-beta.12-license +22 -0
- data/vendor/pug-2.0.0-beta.12.min.js +1 -0
- data/vendor/pug-2.0.0-beta1-license +22 -0
- data/vendor/pug-2.0.0-beta1.min.js +1 -0
- data/vendor/pug-2.0.0-beta10-license +22 -0
- data/vendor/pug-2.0.0-beta10.min.js +1 -0
- data/vendor/pug-2.0.0-beta11-license +22 -0
- data/vendor/pug-2.0.0-beta11.min.js +1 -0
- data/vendor/pug-2.0.0-beta2-license +22 -0
- data/vendor/pug-2.0.0-beta2.min.js +1 -0
- data/vendor/pug-2.0.0-beta3-license +22 -0
- data/vendor/pug-2.0.0-beta3.min.js +1 -0
- data/vendor/pug-2.0.0-beta4-license +22 -0
- data/vendor/pug-2.0.0-beta4.min.js +1 -0
- data/vendor/pug-2.0.0-beta5-license +22 -0
- data/vendor/pug-2.0.0-beta5.min.js +1 -0
- data/vendor/pug-2.0.0-beta6-license +22 -0
- data/vendor/pug-2.0.0-beta6.min.js +1 -0
- data/vendor/pug-2.0.0-beta7-license +22 -0
- data/vendor/pug-2.0.0-beta7.min.js +1 -0
- data/vendor/pug-2.0.0-beta8-license +22 -0
- data/vendor/pug-2.0.0-beta8.min.js +1 -0
- data/vendor/pug-2.0.0-beta9-license +22 -0
- data/vendor/pug-2.0.0-beta9.min.js +1 -0
- data/vendor/pug-2.0.0-rc.1-license +22 -0
- data/vendor/pug-2.0.0-rc.1.min.js +1 -0
- data/vendor/pug-2.0.0-rc.2-license +22 -0
- data/vendor/pug-2.0.0-rc.2.min.js +1 -0
- data/vendor/pug-2.0.0-rc.3-license +22 -0
- data/vendor/pug-2.0.0-rc.3.min.js +1 -0
- data/vendor/pug-runtime-2.0.0-license +19 -0
- data/vendor/pug-runtime-2.0.0.js +266 -0
- data/vendor/pug-runtime-2.0.1-license +19 -0
- data/vendor/pug-runtime-2.0.1.js +266 -0
- data/vendor/pug-runtime-2.0.2-license +19 -0
- data/vendor/pug-runtime-2.0.2.js +267 -0
- metadata +242 -13
- data/lib/jade-ruby/compile.rb +0 -79
- data/lib/pug-ruby/compile.rb +0 -88
|
@@ -0,0 +1,199 @@
|
|
|
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, ''') + "'";
|
|
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
|
+
return String(html).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Re-throw the given `err` in context to the
|
|
162
|
+
* the jade in `filename` at the given `lineno`.
|
|
163
|
+
*
|
|
164
|
+
* @param {Error} err
|
|
165
|
+
* @param {String} filename
|
|
166
|
+
* @param {String} lineno
|
|
167
|
+
* @api private
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
exports.rethrow = function rethrow(err, filename, lineno, str) {
|
|
171
|
+
if (!(err instanceof Error)) throw err;
|
|
172
|
+
if ((typeof window != 'undefined' || !filename) && !str) {
|
|
173
|
+
err.message += ' on line ' + lineno;
|
|
174
|
+
throw err;
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
str = str || require('fs').readFileSync(filename, 'utf8');
|
|
178
|
+
} catch (ex) {
|
|
179
|
+
rethrow(err, null, lineno);
|
|
180
|
+
}
|
|
181
|
+
var context = 3,
|
|
182
|
+
lines = str.split('\n'),
|
|
183
|
+
start = Math.max(lineno - context, 0),
|
|
184
|
+
end = Math.min(lines.length, lineno + context);
|
|
185
|
+
|
|
186
|
+
// Error context
|
|
187
|
+
var context = lines.slice(start, end).map(function (line, i) {
|
|
188
|
+
var curr = i + start + 1;
|
|
189
|
+
return (curr == lineno ? ' > ' : ' ') + curr + '| ' + line;
|
|
190
|
+
}).join('\n');
|
|
191
|
+
|
|
192
|
+
// Alter exception message
|
|
193
|
+
err.path = filename;
|
|
194
|
+
err.message = (filename || 'Jade') + ':' + lineno + '\n' + context + '\n\n' + err.message;
|
|
195
|
+
throw err;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
},{"fs":1}]},{},[2])(2)
|
|
199
|
+
});
|
|
@@ -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,199 @@
|
|
|
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, ''') + "'";
|
|
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
|
+
return String(html).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Re-throw the given `err` in context to the
|
|
162
|
+
* the jade in `filename` at the given `lineno`.
|
|
163
|
+
*
|
|
164
|
+
* @param {Error} err
|
|
165
|
+
* @param {String} filename
|
|
166
|
+
* @param {String} lineno
|
|
167
|
+
* @api private
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
exports.rethrow = function rethrow(err, filename, lineno, str) {
|
|
171
|
+
if (!(err instanceof Error)) throw err;
|
|
172
|
+
if ((typeof window != 'undefined' || !filename) && !str) {
|
|
173
|
+
err.message += ' on line ' + lineno;
|
|
174
|
+
throw err;
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
str = str || require('fs').readFileSync(filename, 'utf8');
|
|
178
|
+
} catch (ex) {
|
|
179
|
+
rethrow(err, null, lineno);
|
|
180
|
+
}
|
|
181
|
+
var context = 3,
|
|
182
|
+
lines = str.split('\n'),
|
|
183
|
+
start = Math.max(lineno - context, 0),
|
|
184
|
+
end = Math.min(lines.length, lineno + context);
|
|
185
|
+
|
|
186
|
+
// Error context
|
|
187
|
+
var context = lines.slice(start, end).map(function (line, i) {
|
|
188
|
+
var curr = i + start + 1;
|
|
189
|
+
return (curr == lineno ? ' > ' : ' ') + curr + '| ' + line;
|
|
190
|
+
}).join('\n');
|
|
191
|
+
|
|
192
|
+
// Alter exception message
|
|
193
|
+
err.path = filename;
|
|
194
|
+
err.message = (filename || 'Jade') + ':' + lineno + '\n' + context + '\n\n' + err.message;
|
|
195
|
+
throw err;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
},{"fs":1}]},{},[2])(2)
|
|
199
|
+
});
|
|
@@ -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, ''') + "'";
|
|
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, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
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
|
+
});
|